How to get value on postback Dynamically Created controls by javas

How to get value on postback Dynamically Created controls by javas

Post by QW5hbmQgUm » Mon, 06 Mar 2006 01:46:20


Amit,

You can use Request.Form["App1"] (C#) or Request.Form("App1") (VB.NET) to
access values of controls created on the client side by javascript.

You may also want to create a hidden text field and update value of that
field with number of textboxes created on the client side.

Then retrieve this (hidden text box) value first on the server side for
count of fields created. Then use Request.Form("") to retrieve values of
textboxes created.

Regards,

Anand.
 
 
 

How to get value on postback Dynamically Created controls by javas

Post by Amit Mahes » Tue, 07 Mar 2006 13:29:11

Thanks for replying Anand, but i could not getting any object using
Request.Form["App1"] and Request.Param["App1"], the error i m getting is
"Object reference not set to an instance of an object. "
And i also looked 'Request.Form' in QuickWatch, there is no key of
App1,App2 which i had created.
It seems that form is not remembring on post back what i have created using
javascript, Is there any way to resolve it?

"Anand Rajagopalan" <Anand XXXX@XXXXX.COM > wrote in


side
controls

 
 
 

How to get value on postback Dynamically Created controls by javas

Post by Kalpes » Tue, 07 Mar 2006 15:26:07

Hi Amit,

I think - the suggestion by Anand should work.
However, check for 2 things

1) form is using POST as against GET
2) javascript code to create TR/TD is appending it to Body instead of a
Table tag

HTH
Kalpesh
 
 
 

How to get value on postback Dynamically Created controls by javas

Post by Amit Mahes » Tue, 07 Mar 2006 17:49:29

Kalpesh form is using method post
<form id="Form1" method="post" runat="server">
and row is appending to body
objTBody.appendChild(objCurRow)

My form looks like this
<HTML>
<HEAD>
|
|
|
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table>
<tr><td>
<input type="button" id="AddAppl" value="Add Application"
onclick="AddApp();">
</td></tr>
<tbody id="AppBody" runat="server">
</tbody>

</table>
</form>
</body>
</HTML>

and the Javasscript code is written in my question.

Is there somthing i am missing ?
 
 
 

How to get value on postback Dynamically Created controls by javas

Post by Kalpes » Tue, 07 Mar 2006 21:40:25

Hi Amit,

It seems that this cannot be achieved.
See this link - http://www.yqcomputer.com/

Also, it will be better to have a hidden field inside your asp.net page
statically available
On user submitting this page, fill the hidden field value with values
of controls that you created dynamically on client side

HTH
Kalpesh
 
 
 

How to get value on postback Dynamically Created controls by javas

Post by Amit Mahes » Tue, 07 Mar 2006 21:42:15

Thanks Kalpesh, I have used the same approach, and it worked.
:)