Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabled Checked checkbox shows as unchecked - ASP.NET

Tags:

html

asp.net

I have a input checkbox that is checked and disabled when some JS runs on page load.

<input name="selectUnionDues" id="selectUnionDues"  type="checkbox" checked="checked" runat="server" />

When I get the value of the checkbox by using (on the server side)

this.selectUnionDues.checked //returns false

I always get a false

EDIT: I am concerned about using heavy asp.net controls since the page size in this application needs to be low. Is there a way out using HTMl controls?

like image 570
DotnetDude Avatar asked Mar 09 '09 22:03

DotnetDude


3 Answers

Disabled form controls are not "successful controls", that means they values aren't "submitted" at all with your form.

like image 162
Christian C. Salvadó Avatar answered Nov 20 '22 09:11

Christian C. Salvadó


check this out https://web.archive.org/web/20211020150718/https://www.4guysfromrolla.com/articles/012506-1.aspx

In short, (1)there is a "SubmitDisabledControls" property of "form" or (2)tweak the javascript the author provided

like image 3
Might Avatar answered Nov 20 '22 09:11

Might


If you disable the checkbox, it always return false. the best idea is to make the checkbox readonly, so that it will return the value as it is. make the readonly="readonly".

like image 1
Arunagirirajah Nirooshan Avatar answered Nov 20 '22 08:11

Arunagirirajah Nirooshan