【发布时间】:2015-06-07 08:01:48
【问题描述】:
我在 Controller 中使用了[prompt("name")] 和
@Html.EditorFor(model => model.Email,
new {placeholder=ViewData.ModelMetadata.Watermark})`
在视图中但没有显示 我还使用了Html5 Placeholders with .NET MVC 3 Razor EditorFor extension? 的帮助 但什么也没发生 我需要 @EditorFor 的占位符而不是文本框 任何帮助表示赞赏
【问题讨论】:
-
文本框有什么问题?您要生成什么类型的控件?对于 MVC-5,您可以使用
Html.EditorFor(m => m.Email, new { htmlAttributes = new { placeholder = ... }, }) -
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { placeholder = "Enter the title Here" } }) 我已经写过了,但什么也没得到
-
在 MVC-5 中?您已将其标记为 MVC-4 和 MVC-5!但为什么不
TextBoxFor()? -
查看为模型的所有属性生成的默认脚手架@EditorFor
-
我假设您的意思是属性,而不是属性。但是为什么不把它改成
TextBoxFor()(如果需要,添加type="email")
标签: c# asp.net-mvc razor asp.net-mvc-5