Reputation: 23531
We recently upgraded an existing .NET 4 MVC 3 project to .NET 4.5 and MVC 4.
Where we had this sort of thing in a view:
@Model.MyBool
<input type="hidden" name="foo" value="@Model.MyBool" />
that used to render as:
True
<input type="hidden" name="foo" value="True" />
or:
False
<input type="hidden" name="foo" value="False" />
But now it renders as:
True
<input type="hidden" name="foo" value="value" />
or:
False
<input type="hidden" name="foo" />
That is, where a boolean property is rendered in the view as the value of a hidden input's value attribute, it doesn't render as True
or False
(as it does elsewhere), but rather renders as value
, or misses the attribute altogether.
Two questions:
Upvotes: 6
Views: 872
Reputation: 5832
WTF?
Razor 2 conditional attributes
Is there a nice easy way I can fix the multitude of places that this has broken my application?
None I can think of (that's why you should have used @Html.Hidden("foo", Model.MyBool)
). My best guess would be using something like Resharper's Structured Replace.
Upvotes: 3
Reputation: 3277
looks like this is working:
<input type="hidden" name="foo" value="@Model.MyBool.ToString()" />
Upvotes: 2