I have a code on server side:
@Html.EditorFor(m => m.RememberMe)
RememberMe is a boolean field of my model.
And the rendered HTML:
<input class="check-box" data-val="true" data-val-required="The Remember Me ? field is required." id="RememberMe" name="RememberMe" type="checkbox" value="true" />
<input name="RememberMe" type="hidden" value="false" />
There is a hidden field with the same name="RememberMe". I don't know why and what is the purpose of this hidden field.
When I debug on server side with the checkbox checked, the model was mapped correctly. I got: myModel.RememberMe = true. But when I inspected the Request["RememberMe"]. I saw "true,false". The false must be from the hidden field as they have same name.
My questions are:
- Will the
falsecause problems? - Why asp.net mvc renders a hidden field like this?
- If the hidden field is not neccesary. How can I get rid of it? I think it's best to get only
"true"forRequest["RememberMe"].
Thank you