【发布时间】:2016-12-31 08:09:52
【问题描述】:
我想通过复选框传递我的布尔值。
这是我的财产
public bool MyBooleanValue{ get; set; } = true;
这里是我的 HTML:
<input type="checkbox" id="@nameof(Model.MyBooleanValue)" name="my-boolean" value="1" class="" checked="checked" />
<label for="@nameof(Model.MyBooleanValue)">some text</label>
<input type="hidden" name="my-boolean" value="true" />
默认情况下,我希望选中字段。这段代码有什么问题? 我使用 ASP.NET MVC 5。 我总是得到相同的值
【问题讨论】:
-
只要使用
@Html.CheckBoxFor(m => m.MyBooleanValue)
标签: html asp.net-mvc asp.net-mvc-4 razor checkbox