最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting a value of a disabled HTML checkbox using Request.Form - Stack Overflow

programmeradmin1浏览0评论

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

Share Improve this question asked Dec 28, 2010 at 21:59 DotnetDudeDotnetDude 11.8k38 gold badges103 silver badges159 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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 bee enabled on the client-side, you can have them change the value of the hidden element onchange, so that the values match.

发布评论

评论列表(0)

  1. 暂无评论