I am trying to create a form with MVC4 and so far it is going well, but I have run into a problem where is doesn't seem possible to give my inputs a default value by setting the associated 'value' attribute.
The code that I am using:
@Html.TextBoxFor(x => x.Name, new { value="xxx" })
renders the following:
<input id="EditDetail_SKU" name="EditDetail.SKU" type="text" value="" />
That is kind of annoying because the value attribute is now empty. It seems that I can add all sorts of attributes after the fact, and they are respected, ala:
@Html.TextBoxFor(x => x.Name, new { value="xxx", thing="whatever",foo="bar" })
Yields:
<input foo="bar" id="name" name="Name" thing="whatever" type="text" value="" />
Those attributes are even made up, but they are still respected, so why is 'value' being ignored in this case, and is there something I can do prevent this?