|
-
Feb 23rd, 2004, 04:25 AM
#1
Thread Starter
New Member
How to get which checkbox is checked? (In 150 checkbox)
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.
-
Feb 23rd, 2004, 08:03 AM
#2
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.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 23rd, 2004, 08:20 AM
#3
Thread Starter
New Member
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'.
-
Feb 23rd, 2004, 08:26 AM
#4
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.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 23rd, 2004, 08:31 AM
#5
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|