I have written the below code on my view page;
@Html.CheckBox("ChxName",true)
and I got the following result;
<input checked="checked" id="ChxName" name="ChxName" type="checkbox" value="true" />
<input name="ChxName" type="hidden" value="false" />
why is there a input element named as the same with checkbox?
Unchecked checkboxes are not posted, so the hidden field (set as false) allows the model binding to still work.
Look at Request.Form on the post back. If the checkbox is checked, you’ll see:
The model binder uses the first value.
and, if the box isn’t checked, you’ll see: