ASP.Net Checkbox value at postback is wrong?

This is a known problem with ASP.NET – for some reason ASP.NET won’t update a checkbox on postback if it was disabled during page load and not checked for postback. I don’t know exactly why that is though – if you make the checkbox unselected by default and select it, the value is changed on the server correctly.

The workaround is to add a hidden field to the page that represents the state of the checkbox, then update the field’s value to “ON” or “OFF” for example, whenever the checkbox is clicked.

Then on the server you check the value of the hidden field, not the checkbox itself, as the hidden field is always posted.

Leave a Comment