Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,
i am using html label and text box for generating dynamic control on aspx page.
I got the text box values but not label control value. i used label for column name on the bases of column name i insert value into datatbase.
Here is my code...
HTML
<tr id="ContentPlaceHolder1_hd2">
		<td><label id="lbl_2" name="lbl_2" text="sfsdfd">Company</label></td>
		<td><input type="text" style="width:200px;" id="txt_Company2" name="txt_Company2" maxlength="255" "=""></td>
	</tr>

in c#
C#
return Request.Form[controlID];


so, that when i pass the text box control id like 'txt_Company2' then is returns the value but while i pass the label id like 'lbl_2' it returns null. i debugs the c# code "Request.Form" it shows me all text box ID's but not label's ID.

Note: I can't be use server control because it is dynamic so it lost its identity after postback.

So, please suggest any work around.
Posted

1 solution

You can use javascript here like:
document.getElementById('<%=ID-value.ClientID%>')
 
Share this answer
 
Comments
Er. Vikas Sangal 13-Feb-15 5:56am    
Thanks for your comment,okay but how to insert values into database through javascript
anujshaarma 13-Feb-15 6:47am    
Kindly refer the below article for this, he is using JQuery JSON
http://www.dotnetspan.com/2014/08/Example-jquery-ajax-json-call-in-asp-net-code.html
Er. Vikas Sangal 16-Feb-15 2:38am    
Thanks for your comments but here we don't know the column name.
I found the way out from this..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900