Thursday, October 13, 2011

Checked False Disabled HTML CheckBox

Checked property is false for disabled html checkbox

If an html checkbox is disabled through javascript and the form is submitted, the checked property of the disabled checkbox will always come up as false. This happens because when a an html control is disabled, it is not included in the post back. Hence, the checked property will always be false.

One potential solution to this problem is to enable the checkbox through javascript when submitting the form. Usually, this happens when some javascript is called to validate the form. We can enable back the checkbox at this point so that the actual value of checked property can be included in the postback.

Another possible solution is to replace html checkbox with ASP .Net checkbox control. You can choose one of these solutions as per your situation.