admin管理员组文章数量:1414628
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
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
2 Answers
Reset to default 5You 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 bee enabled on the client-side, you can have them change the value of the hidden element onchange
, so that the values match.
本文标签: javascriptGetting a value of a disabled HTML checkbox using RequestFormStack Overflow
版权声明:本文标题:javascript - Getting a value of a disabled HTML checkbox using Request.Form - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745179613a2646406.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论