0

I'm using Asp.Net MVC4 technology. I'm trying to override default style property of Html.EditorFor but its not working. Here is my code.
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) And here is output from the browser.

<input id="Name" class="text-box single-line valid" data-val="true"data-val-required="The User Name field is required." name="Name" type="text"/>
  • This code looks fine. I just copied and pasted that line to a local project and it did add that css class to the input form element. – Shyju Jul 31 '16 at 16:24
  • Possible duplicate of [unable to apply Bootstrap classes to my EditorFor](http://stackoverflow.com/questions/27975810/unable-to-apply-bootstrap-classes-to-my-editorfor) –  Jul 31 '16 at 22:43
  • Adding html attributes with `EditorFor()` is only supported in MVC-5.1+. Use `TextBoxFor()` –  Jul 31 '16 at 22:43
  • Thanks..... I just Updated my MVC version and it worked. – Rizwan Ijaz Aug 08 '16 at 19:29

0 Answers0