How to set bootstrap checkbox in razor CheckBoxFor()

后端 未结 5 1750
萌比男神i
萌比男神i 2021-01-06 01:25

I want to use bootstrap styled checkbox in my asp .net mvc form, however I find it very difficult. After hours looking for solution, I couldn\'t find anything that works for

5条回答
  •  广开言路
    2021-01-06 01:27

    its not working because of putting the class in div so add the class in checkbox like this

                    
    @Html.LabelFor(c => c.IsSynchronize, new { @class = "col-sm-2 control-label" })
    @Html.CheckBoxFor(model => model.IsSynchronize ,new {@class="checkbox"})

    btw i use icheck which are a bit fancy you just have to add

    
    
    

    these libraries in header and in code use

     
    @Html.CheckBoxFor(model => model.IsSynchronize) @Html.LabelFor(c => c.IsSynchronize, new { @class = "col-sm-2 control-label" })

提交回复
热议问题