Is there a way to write the Html5 placeholder using @Html.EditorFor, or should I just use the TextBoxFor extension i.e.
@Html.TextBoxFor(model => model.Title, new { @placeholder = "Enter title here"})
Or would it make sense to write our own custom extension that can maybe use the 'Description' display attribute via DataAnnotations (similar to this)?
Of course, then the same question applies to 'autofocus' as well.
I've wrote such a simple class:
The usage as such:
And property in a viewmodel:
Notice Prompt parameter. In this case I use strings from resources for localization but you can use just strings, just avoid ResourceType parameter.
I actually prefer to use the display name for the placeholder text majority of the time. Here is an example of using the DisplayName: