Auto checking the checkbox in ASP.NET MVC

Posted by Sheonarayan under Error and Solution on 10/18/2013 | Points: 10 | Views : 2631 | Status : [Administrator] | Replies : 0

To auto check the checkbox in ASP.MVC using CheckBoxFor use below approach.

<div class="editor-field">
Model.IsActive = true;
@Html.CheckBoxFor(m => m.IsActive)

In the above code, first I set the IsActive property of the model that is bounded to this page to true and then used Html.CheckBoxFor helper element and set its value to the Active property of the model object.

This will do the trick.

Sheo Narayan


(No response found.)

Login to post response