Accessing dynamically created controls from code-behind

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
 
A

avnrao

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

Av.
 
S

Steve Black

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top