Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi every one I have a simple web application that has some check boxes I want make two of them Mutually Exclusive then I write on Protected Sub CheckBox3_CheckedChanged event and Protected Sub CheckBox4_CheckedChanged this code :
VB
If CheckBox4.Checked = True Then CheckBox3.Checked = False
If CheckBox3.Checked = True Then CheckBox4.Checked = False



but it is not work
can u help me !
Posted
Comments
ZurdoDev 18-Sep-15 13:37pm    
Use javascript instead of VB so that your page does not have to postback everytime. Tons of examples online of how to check if a box is checked and how to do something when it is.

While this could be done by wiring the CheckedChanged as you have tried, I would suggest using RadioButton[^] instead. With check boxes the user expects that individual check boxes typically work independently so if the choice for the user is a single choice from multiple options, then it's a good practice to use radio buttons
 
Share this answer
 
Comments
rezaeti 18-Sep-15 13:34pm    
hi thanks but I use six check boxes in my web form and I want use chekbox for all to be same how can make two checkbox Mutually Exclusive
rezaeti 18-Sep-15 13:36pm    
in my windows app vb.net this code work successfully but in asp.net web form with vb.net not work why?
Wendelius 18-Sep-15 13:40pm    
Modify the question to contain all the appropriate code. How have you wired the CheckedChange event etc.
Sergey Alexandrovich Kryukov 18-Sep-15 18:08pm    
5ed. The adequate control is a set of radio buttons, not check boxes.
—SA
Wendelius 19-Sep-15 1:54am    
Thank you.
Using RadioButton (or Radio Button List) makes more sense than using a checkbox.
Try
Radiobutton class[^]
Radio Button List[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Sep-15 18:08pm    
Sure, a 5.
—SA
Abhinav S 18-Sep-15 23:37pm    
Thank you SA.
rezaeti 19-Sep-15 12:30pm    
I can do by set property of checkbox (autopostBack)
Is this ok ?
Wendelius 19-Sep-15 1:55am    
Agree, a 5.
Abhinav S 19-Sep-15 2:02am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900