Boolean with html helper Hidden and HiddenFor

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2010-03-08T09:45:52Z Indexed on 2010/03/08 16:51 UTC
Read the original article Hit count: 1102

What's up with this? The viewmodel variable is a bool with value true.

<%= Html.HiddenFor(m => m.TheBool) %>
<%= Html.Hidden("IsTimeExpanded",Model.TheBool) %>
<input type="hidden" value="<%=Model.TheBool%>" name="TheBool" id="TheBool">

Results in:

<input id="TheBool" name="TheBool" value="False" type="hidden">
<input id="TheBool" name="TheBool" value="False" type="hidden">
<input value="True" name="TheBool" id="TheBool" type="hidden">

What am I doing wrong? Why don't the helpers work as intended?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about html-helper