Possible Duplicate:
ASP.NET MVC:Why does the CheckBoxFor render an additional input tag and how can I get the value using the FormCollection
I needed to create a check box and bind the model to the check box. Assume instead of the model value im just assigning false as the value. Code given bellow.
@Html.CheckBox("abcd",false)
Output:
<input id="abcd" name="abcd" type="checkbox" value="true" />
<input name="abcd" type="hidden" value="false" />
The output of the HTML being generated is shown above. I do understand why the hidden check box is put by the razor view engine. My question is if the value is false then the check box visible should be value="false"
(unchecked).
Why it has put value="true"
(checked). Same applies for the checkboxfor helper. What is wrong or could you explain how to implement this?