@Html.EditorFor(x => x.Remember)
Will generate:
<input id="Remember" type="checkbox" value="true" name="Remember" />
<input type="hidden" value="false" name="Remember" />
How does it work:
- If
checkboxremains unchecked, the form submits only thehiddenvalue (false) - If checked, then the form submits two fields (false and true) and MVC sets
truefor the model’sboolproperty
<input id="Remember" name="Remember" type="checkbox" value="@Model.Remember" />
This will always send the default value, if checked.