I\'m trying to add a class to an input.
This is not working:
@Html.EditorFor(x => x.Created, new { @class = \"date\" })
As of ASP.NET MVC 5.1, adding a class to an EditorFor
is possible (the original question specified ASP.NET MVC 3, and the accepted answer is still the best with that considered).
@Html.EditorFor(x=> x.MyProperty,
new { htmlAttributes = new { @class = "MyCssClass" } })
See: What's New in ASP.NET MVC 5.1, Bootstrap support for editor templates