Why is my first radiator not being tested?
I got the following Html:
<div class="horizontalRadio">
<label for="SearchBag.DisplayTypeChips" id="DisplayTypeChipsLabel">
<%=ViewData.Model.T9nProvider.TranslateById("CommonWeb.Chips")%>
</label>
<%=Html.RadioButton("displayType", DisplayTypes.Chip,
Model.DisplayType.Equals(DisplayTypes.Chip.ToString(), StringComparison.InvariantCultureIgnoreCase),
new { @id = "SearchBag.DisplayTypeChips" })%>
</div>
<div class="horizontalRadio">
<label for="SearchBag.DisplayTypeGrid" id="DisplayTypeGridLabel">
<%=ViewData.Model.T9nProvider.TranslateById("CommonWeb.Grid")%>
</label>
<%=Html.RadioButton("displayType", DisplayTypes.Grid,
Model.DisplayType.Equals(DisplayTypes.Grid.ToString(), StringComparison.InvariantCultureIgnoreCase),
new { @id = "SearchBag.DisplayTypeGrid" })%>
</div>
Whenever there Model.DisplayType
is a "grid" everything is fine; the second button is checked.
When the value is "chip", nothing is checked. In the debugger I can see that Model.DisplayType.Equals(DisplayTypes.Chip.ToString())
is true. When I change the name of the buttons to something else, this works too.
Sometimes I don't want to change my name because the name makes sense. This is the name I use throughout the application ...
Any ideas WHY is this name evil?
a source to share
There is a problem in ASP.NET MVC where you have a property on your model with the same name as the name of the "grouped" element (like a selection or radio group).
See http://weblogs.asp.net/ashicmahtab/archive/2009/03/27/asp-net-mvc-html-dropdownlist-and-selected-value.aspx for details .
It might be worth trying.
a source to share