Accessing dynamically created controls from code-behind

  • Thread starter Thread starter Steve Black
  • Start date Start date
S

Steve Black

Hello,

I am dynamically creating checkboxes on my web page based on data in a
SQL Server table. Therefore, these checkboxes do not exist at design
time and I cannot refer to them in my server-side code at design time.

Once the page is submitted, how can I access these checkboxes in my
code-behind?

Thanks for the help,

Steve
 
You can use Request.Form["controlName"] to access them. this is for just
reading the value.

Av.
 
I see. Thank you.

However, now I have a follow-up question. How can I access
dynamically-defined attributes of my radio button (I accidentally said
checkbox before but I meant radio button)?

I am creating my radio buttons as follows:

rdBtn = New RadioButton
With rdBtn
.ID = ....
.GroupName = "GroupName"
.Attributes.Add(Key1, Value1)
.Attributes.AdD(Key2, Value2)
End With

I then add this radio button (and many others with the same Group Name)
to the web page.

I see that when I submit the page and I try Request.Form("GroupName"), I
can get the ID of the selected radio button. However, I'm not sure how
to access the Attributes which are critical to my application.

Thanks again,

Steve
 
Back
Top