我想在 Html.EditorFor 中使用占位符属性,所以我就像第一个答案中那样:Html5 占位符与 .NET MVC 3 Razor 编辑器用于扩展? https://stackoverflow.com/questions/5824124/html5-placeholders-with-net-mvc-3-razor-editorfor-extension
但在最后一部分,我没有 EditorTemplates 文件夹,所以我创建了它,当我尝试创建 string.cshtml 视图时,我不能,因为名称“string”被保留,所以我选择了 stringg.cshtml ,它没用!我必须在程序中的其他地方更改名称吗?我确实很喜欢这个答案...
谢谢你!
升级到MVC 5.1,您可以在EditorFor中使用HTML属性:
@Html.EditorFor(m => m.variable, new { htmlAttributes = new { placeholder = "Your Placeholder Text" } })
http://www.asp.net/mvc/overview/releases/mvc51-release-notes http://www.asp.net/mvc/overview/releases/mvc51-release-notes
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)