[RESOLVED] Real-time control effect via code behind


I have two checkboxes on web form chkYes and chkNo. When I click either I want the other one to be un-ticked. I have implemented the following in code behind;

protected void chkNo_CheckedChanged(object sender, EventArgs e)
  this.chkYes.Checked = false;
protected void chkYes_CheckedChanged(object sender, EventArgs e)
  this.chkNo.Checked = false;

Problem is ticking one tick has no effect on the other. What is the reason and how can I make it work?



you'd need to set the checkbox's autopostback property to true to see the code run as soon as you click.

note - I think that you might want to check to see if the checkbox that is firing its changed event is actually checked before you uncheck the other one..??

keep in mind that doing postbacks can be heavy, so you might also want to consider a client side jQuery solution for mutually exclusive checkboxes.


Hi, You can use AJAX MutuallyExclusiveCheckBoxExtender without post back of page

see: http://www.asp.net/ajax/tutorials/creating-mutually-exclusive-checkboxes-vb

but best is use radio button list it ment for single select only

also see:



you can make this one happen on client side itself....there is no need for you to make a round trip to server for this requirement...

make use of javascript....try this...



thoughts on "[RESOLVED] Real-time control effect via code behind"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>