Is there a shorter way to get which checkbox checked in 150 checkbox other than;
if checkbox1.checked = true then .....
if checkbox2.checked = true then .....
if checkbox150.checked = true then .....
Thanks in advance.
Printable View
Is there a shorter way to get which checkbox checked in 150 checkbox other than;
if checkbox1.checked = true then .....
if checkbox2.checked = true then .....
if checkbox150.checked = true then .....
Thanks in advance.
VB Code:
Dim cb As CheckBox Dim c As Control For Each c In Controls If TypeOf c Is CheckBox Then cb = c If cb.Checked Then Response.Write(cb.Name & " is checked") End If End If Next
Something like that.
Thank for reply. But I am very new to this.
Do I have to import some namespace for that? Cause its gives me this compile error at this line
Response.Write(cb.Name & " is checked")
Error;
Compiler Error Message: BC30456: 'Name' is not a member of 'System.Web.UI.WebControls.CheckBox'.
No, its just me confusing things. I was thinking of regular applications when I should have been thinking ASP. Try replacing Name with ID and it should work fine.
Worked. Thanks a lot.