开发者

Getting a value of a disabled HTML checkbox using Request.Form

开发者 https://www.devze.com 2023-02-01 06:42 出处:网络
I have a html checkbox <input type=\"checkbox\" name=\"MyChkBox\" .. /> There is another control that makes this enable/disabled and I am doing that using JQuery

I have a html checkbox

<input type="checkbox" name="MyChkBox" .. />

There is another control that makes this enable/disabled and I am doing that using JQuery

$(this).attr("disabled", "true");

On the server, I get the checkbox values using:

string info = Request.Form["开发者_如何学运维MyChkBox"];

My problem is if a checkbox is checked and disabled, I need to be able to get this value using Request.Form


You can't do this, you'll need to re-enable it to see/get it server-side (otherwise the client won't send it at all). The browser doesn't include disabled controls in the <form> submission, since they don't count as "successful" controls.


You could have the checkboxes there for display purposes, and have some hidden fields that contain the actual values that are passed to the server.

If the checkboxes ever need to become enabled on the client-side, you can have them change the value of the hidden element onchange, so that the values match.

0

精彩评论

暂无评论...
验证码 换一张
取 消