这是我的模型
public class ValidationModel
{
#region Properties
[Display(Prompt = "type a PostCode here")]
public string PostCode { get; set; }
}
这是我的看法
@using (Html.BeginForm())
{
@Html.LabelFor(m => m.PostCode)
@Html.TextBoxFor(m => m.PostCode)
}
有没有办法让它渲染
<input data-val="true" id="PostCode" name="PostCode" placeholder="type a PostCode here" type="text" value="" />
即使从文档http://bit.ly/jVpM8X我也无法让它工作我可以清楚地看到 Display Prompt 应该可以完成这项工作
最佳答案
@Html.TextBoxFor(m => m.PostCode,
new { placeholder = "type a postcode ..." } )
关于c# - 在#MVC3 中有没有办法使用 DataAnnotations 属性添加 HTML5 占位符属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6375039/