MVC5 placeholder for input not working

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 appear as I added in the code, but it doesn't appear. Can anyone point out what I am doing wrong? HTML output

<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;">

      

+3


source to share


1 answer


This is an overload only EditorFor

accepting htmlAttributes

for MVC 5.1.

See HERE



If updating is not an option, use TextBoxFor

:

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

      

+11


source







All Articles