开发者

Checkbox doesn't render

开发者 https://www.devze.com 2023-03-13 06:31 出处:网络
This is what I did on the view. I put @Html.CheckBox(\"checkBox\", false, \"Name\") in a jQuery UI tab.

This is what I did on the view. I put @Html.CheckBox("checkBox", false, "Name") in a jQuery UI tab.

But on the rendered html, this checkbox control was evaluated as a html string

<input 开发者_如何学运维id="checkBox" name="checkBox" type="checkbox" value="true" /><input name="checkBox" type="hidden" value="false" /><label for="checkBox">Name</label> 

rather than a control. Any idea?


The default for Html.CheckBox also creates a hidden input tag.

This will return the value you get when the checkbox is not checked. Due to the nature of html, if a checkbox is not checked, nothing will be posted. So this is the easiest workaround.

0

精彩评论

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