Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I created a page dynamically check below the example
C#
label l=new label()
l.id="lbltest"
l.text+="<div id=name name=name  runat="server"><br />"
l.text+="<div id=age name=age  runat="server"><br />"
l.text+="<div id=gender name=gender  runat="server"><br />"


my question is as follows I want to assign values to name and age. How can that be done?

I have tried to do it using javascript
C#
document.getElementById("name").value="test"

but got an error NULL POINTER how can assign value to div on page load?
Posted
Updated 23-Oct-12 1:40am
v2
Comments
I.explore.code 23-Oct-12 8:30am    
why do u want to do that? You will surely get a null pointer because JS code would run before the server side has a chance to run and would try to populate values in controls that don't yet exist.
hhh12 23-Oct-12 8:49am    
any other way I can assign value to the div's?
hhh12 23-Oct-12 14:04pm    
Can anyone suggest a solution?
hhh12 23-Oct-12 15:19pm    
finally fixed the problem !

1 solution

Any suggestions as I am out of ideas! I have tried everything but didn't manage to solve my problem.
 
Share this answer
 

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