Click to See Complete Forum and Search --> : Strange Radiobutton problem!!


kmansari
December 16th, 2002, 05:04 PM
I am a newbie to .NET and web programming.

I have a webform with two radio buttons. Initially when the page loads, the first radiobutton is unchecked and the second one is checked. There is also a checkbox and a textbox associated with the RadioButton1. Since RadioButton1 is unchecked initially, the checkbox and the textbox remain disabled.

When the user switches from RadioButton2 to RadioButton1, the code should enable the checkbox and the textbox, and vice-versa.

So far, I've mentioned what must happen when the user switches back and forth between the two radio buttons.

This is what is actually happening...

The page loads properly with RB1 unchecked, RB2 checked, CB disabled, TB disabled.

When I click on RB1, the UI responds properly by unselecting RB2, and selecting RB1. However, it DOES NOT call the handler for RadioButton1 (RB1_CheckedChanged). Because of the handler not getting called, my checkbox and textbox remain in the disabled state. I used a breakpoint inside the handler code to verify that the handler fails to get control.

Next, I clicked on RB2. As expected, my code unselected RB1, selected RB2, CB disabled, TB disabled. Everything as expected...

However, when I click on RB1 this time, it DOES call my handler for RB1 (verified using a breakpoint). It also brings my CB and TB in enabled mode.

So in short, the handler for my RadioButton1 fails to get invoked the first time; however, second time onwards, it works as expected.

Has anyone ever encountered this problem before?
Does anybody have a solution?
Any ideas / suggestions to try?

BTW, because of the design requirements, I CANNOT use a radiobutton list. What I have right now is two separate radiobuttons.

Thanks to all of you in advance,
-kmansari