Skip to content Skip to sidebar Skip to footer

Disable A Checkbox In Javascript And Recognize It As Checked On The Server Side

I have a checkbox which in some cases may be disabled and checked using javascript, i.e: var cbTest = document.getElementById('CheckBoxTest'); cbTest.disabled = true; cbTest.checke

Solution 1:

Any disabled control inside a form will not submitted to server on post back. You can add a hidden input control and put the checkbox state to that input and server side check that hidden input value.

Solution 2:

To get a disabled field's value you'll have to enable it just before the postback. The avalue of a disabled field is never send.

Solution 3:

You can either enable the checkbox before the post, or set up a hidden field to hold the value of the checked state. A disabled control won't post its value.

Solution 4:

I think that HTML forms only post the values of enabled controls. I guess one way around this would be to have a hidden field (<input type="hidden"/>), and to store the Checked status of the CheckBox in here.

Solution 5:

Have you tried to get the Attribute like

string val = checkbox.Attributes["checked"].ToString();

Post a Comment for "Disable A Checkbox In Javascript And Recognize It As Checked On The Server Side"