In .NET MVC, Html.CheckBoxFor is a helper method used to generate a checkbox input element that is bound to a model property. It ensures the checkbox’s state reflects the model’s value and automatically handles binding for both checked and unchecked states. Here’s an example:
@model MyModel
@Html.CheckBoxFor(model => model.IsActive)
In this example, IsActive is a boolean property in the model. If the value is true, the checkbox will be checked; if false, it will be unchecked. This ensures data binding between the checkbox and the model’s property.