I just noticed that Html.CheckBox("foo")
generates 2 inputs instead of one, anybody knows why is this so ?
<input id="foo" name="foo" type="checkbox" value="true" />
<input name="foo" type="hidden" value="false" />
If checkbox is not selected, form field is not submitted. That is why there is always false value in hidden field. If you leave checkbox unchecked, form will still have value from hidden field. That is how ASP.NET MVC handles checkbox values. If you want to confirm that, place a checkbox on form not with Html.Hidden, but with | |||||
|
when the check box is checked and submitted perform this
| |||
|
The manual approach is this:
| |||||||||||||
|