首页 > 解决方案 > 将引导开关应用于复选框

问题描述

在我的 asp.net mvc 应用程序中,表单中有我创建的几个输入。

在这里我也使用主题,我想更改我的复选框model.Add_GeneralRequest以切换按钮。

我从我使用的主题中找到了一个切换按钮,但我很难将这种风格添加到现有代码中。

这是我的html代码。

<div class="form-group">
  @Html.LabelFor(model => model.Add_GeneralRequest, htmlAttributes: new { @class = "control-label col-md-2" })
   <div class="col-md-10">
      <div class="checkbox">
         @Html.EditorFor(model => model.Add_GeneralRequest)
         @Html.ValidationMessageFor(model => model.Add_GeneralRequest, "", new { @class = "text-danger" })
      </div>
    </div>
</div>

这是我从主题中得到的课程,

<div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate bootstrap-switch-on bootstrap-switch-focused" style="width: 86px;">
   <div class="bootstrap-switch-container" style="width: 126px; margin-left: 0px;">
     <span class="bootstrap-switch-handle-on bootstrap-switch-success" style="width: 42px;">ON</span>
     <span class="bootstrap-switch-label" style="width: 42px;">&nbsp; 
     </span>
    <span class="bootstrap-switch-handle-off bootstrap-switch-danger" style="width: 42px;">OFF</span>
   <input type="checkbox" name="my-checkbox" checked="" data-bootstrap-switch="" data-off-color="danger" data-on-color="success"></div></div>

我已将所有脚本添加到视图中,但在主题切换工作中它不会像明智的那样工作。另外我想知道如何将此开关应用于所需的列(model.Add_GeneralRequest 这应该从开关更新 true 或 false)。

标签: c#htmlasp.net-mvcasp.net-mvc-4bootstrap-themes

解决方案


推荐阅读