How can I get my select list to render without HTML coding
@{
var noiceList = new SelectList(new[] { new {ID = "", Name = ""},
new {ID = "y", Name = "Yes after3Space"},
"ID", "Name");
}
@Html.DropDownList("noice", @noiceList )
rendered
..
<option value="y">Yes&nbsp;&nbsp;&nbsp;3Space</option>
...
How do I get it to instead render
<option value="y">Yes after3Space</option>
The easiest way to achieve this in C# is to use
\xA0instead of so you can avoid all that extra code.Credit goes to this answer: How to retain spaces in DropDownList – ASP.net MVC Razor views