I used [prompt("name")] in Controller and
@Html.EditorFor(model => model.Email,
new {placeholder=ViewData.ModelMetadata.Watermark})`
in view but nothing showed I also used help of Html5 Placeholders with .NET MVC 3 Razor EditorFor extension? but nothing happened I need Placeholder for @EditorFor not for Textbox Any Help Appreciated
You can write HTML attributes into Html.EditorFor using the following syntax. Make sure you use @ before class and placeholder so that the renderer knows this is HTML markup.
@Html.EditorFor(model => model.Email, new {
htmlAttributes = new {
@class = "form-control",
@placeholder = "Email Address"
}
})
EditorFor doesn't accept HtmlAttribut argument you have to use TextBoxFor instead of it ;) try this:
@Html.TextBoxFor(model => model.Email, new {placeholder=ViewData.ModelMetadata.Watermark})`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With