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. 

@Html.CheckBox("Active1")

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

Ouptut

<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) 

Ouptut

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



Write for us






Hosting Recommendations