ASP.NET MVC > View - Form specific

Check box in razor view in ASP.NET MVC

How to create a checkbox in the ASP.NET MVC view?

To create a CheckBox, we can use @Html.CheckBox html helper method. 


Above code snippet creates a checkbox whose name attribute would be "Active1"


<input type="checkbox" name="Active1" />

If the View is using Model and the property is of type Bit (Boolean), we can use @Html.CheckBoxFor 

 @Html.CheckBoxFor(model => model.Active) 


<input type="checkbox" name="Active" />
 Views: 3739 | Post Order: 29

Write for us