1
我想通过复选框传递我的布尔值。通过复选框传递布尔值
这里是我的财产
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)' –