3

My code is like this

 @Html.EditorFor(model => model.CreatedUser, new { htmlAttributes = new { @class = "form-control" ,@placeholder = "Your Placeholder Text"  }})

I expect the placeholder to come up as I added in the code, but it's not showing. Can anyone point out what I am doing wrong? Output HTML

<input class="text-box single-line" id="CreatedUser" name="CreatedUser" type="text" value="" autocomplete="off" style="cursor: auto;  background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;">
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
None
  • 5,582
  • 21
  • 85
  • 170

1 Answers1

12

That EditorFor overload that accepts the htmlAttributes is MVC 5.1 only.

See HERE

If upgrading is not an option, use TextBoxFor:

@Html.TextBoxFor(model => model.CreatedUser, new { @class = "form-control" ,@placeholder = "Your Placeholder Text" })
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148