我正在使用@Html.CheckBoxFor
,并试图在此html助手上应用引导程序类,但当我在此助手上应用该引导程序类时,它将变为只读。你能帮我如何在数据库中使用MVC控制器提交1或0吗。
@Html.CheckBoxFor(m => m.IsStreamProcessing, new { @class = "custom-control-input" } )
<label class="custom-control-label" for="customSwitch1">Stream Processing</label>
由于您已经在使用Bootstrap,我建议您改用Bootstrap Toggle,它应该按预期工作:
@Html.CheckBoxFor(x => item.IsStreamProcessing, new { data_toggle = "toggle",
data_onstyle = "success" })
但是,您需要参考以下内容:
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>