ASP.NET RAZOR-如何在自定义Boostrap 4复选框开关上绑定剃须刀复选框
问题描述:
我如何将剃刀产生的代码放在此开关上?
How would I put the codes generated by the razor on this switch?
它将像ckeckbox一样工作
It would work like the ckeckbox
以下是其工作原理的链接: https://bootsnipp.com/snippets/GaxR2
An here is the link how its work: https://bootsnipp.com/snippets/GaxR2
<div class="card" style="margin:50px 0">
<div class="card-header">Checkbox to Switch</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">
Bootstrap Switch Success
<label class="switch ">
<input type="checkbox" class="success">
<span class="slider"></span>
</label>
</li>
</ul>
</div>
剃刀代码
<div class="form-group">
@Html.LabelFor(model => model.ExibirInfoPosicionamento, htmlAttributes: new { @class = "control-label " })
<div class="col-md-10">
@Html.CheckBoxFor(model => model.ExibirInfoPosicionamento, new { })
</div>
</div>
答
来晚了,但我对此也感到沮丧,让它像这样工作(Bootstrap 4.3.1)
Little late but I had some frustration with this too, got it working like this (Bootstrap 4.3.1)
页面上的剃刀-
<div class="col-lg-1">
@Html.EditorFor(m => Model.YN,"toggle", new { @id = "yn1 })
</div>
编辑器模板切换"
@model System.Boolean
<div class="custom-control custom-switch">
@Html.CheckBoxFor(m => m,
new { @class = "custom-control-input" })
@Html.LabelFor(m => m, new { @class = "custom-control-label" })
</div>