How do you access a dynamically created control's values on the server side?

burak

Centurion
Joined
Jun 17, 2003
Messages
127
Hello,

I would like to dynamically create a radio button by
assigning this string to a label or a literal

<input type="radio" name="AJB" value="YES"
onClick="javascript:toggle('YES','radGrantAllPermissions');"
runat="server" id="Radio1">

How would I then access this control on the server
side?

Thank you,

Burak
 
Instead of creating the string as a literal you can add the control as an asp control

Dim myRadio as new radioButton

myPanel.Controls.Add(myRadio)
myRadio.Attibutes.Add("OnClick", "javascript:toggle('YES','radGrantAllPermissions');")
myRadio.ID = "Radio1"

Then to find the control....


Dim myRadio as new radiobutton

myRadio = DirectCast( myPanel.FindControls("Radio1"),RadioButton)
If not myRadio is nothing then
'do something with the radio button
else
'we did not find the control
end if
 
Remember that if you add a dynamic control to a webform, you have to recreate it and added to the controls collection at every postback
 
Back
Top