MVC4 input field placeholder

An alternative to using a plugin is using an editor template. What you need to do is to create a template file in Shared\EditorTemplates folder and call it String.cshtml. Then put this in that file:

    new { placeholder = ViewData.ModelMetadata.Watermark })

Then use it in your view like this:


The downside, this works for properties of type string, and you will have to create a template for each type that you want support for a watermark.

Leave a Comment