Friday, April 6, 2007

Changing Value of RadioButton Does Not Change Form

ASP.Net 2.0 Server Side RadioButton
I had two RadioButtons in the same group on a form. I created a server side handler for the CheckChanged event. If a certain criteria was true then I needed to show an error and set the checked property back to its previous value. The problem I ran into was that it wasn't updating the form.

As I looked at the source of the page I found that both radiobuttons had their checked attribute set to "checked". It appears that it displays as checked whichever is the last radiobuton with its attribute set. The remedy was to manually set both radiobuttons' checked property on the server and not assume that setting the checked property to true of one that is in the same group that the other would automatically get set to false.

No comments: