views:

514

answers:

1

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?

A: 

1) use different (unique) ids

2) don't use this helper, use

<input type="hidden" name="the-name" 
  value="<%= Html.AttributeEncode(Model.TheBool) %>" id="TheBool_1216786" />
igor
The id is for example only, auto set by the helper and have nothing to do with the result. The question was: why don't the helpers work as intended?
Martin
It is question that should be addressed to MS, many people got so strange behaviour (I found at less one the same problem requests from other person). I tried to help how to resolve or avoid it. I don't work in MS. :) I have not got any thanks from you, so I don't understand why you so critical to my help.
igor
I appreciate you trying to help me. It's just that you didn't help me. In fact you provided no relevant information that was not already in the question. Please direct me to the question you mentioned.
Martin
It seems this is your situation: http://aspnet.codeplex.com/WorkItem/View.aspx?WorkItemId=5089
igor
Well now, that was helpful. :)
Martin