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)' –