我的代码是这样的
@Html.EditorFor(model => model.CreatedUser, new { htmlAttributes = new { @class = "form-control" ,@placeholder = "Your Placeholder Text" }})
我希望占位符会在我在代码中添加时出现,但它没有显示。谁能指出我做错了什么?
输出 HTML
<input class="text-box single-line" id="CreatedUser" name="CreatedUser" type="text" value="" autocomplete="off" style="cursor: auto; background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;">
That EditorFor
接受的重载htmlAttributes
仅适用于 MVC 5.1。
See HERE http://www.asp.net/mvc/overview/releases/mvc51-release-notes
如果无法升级,请使用TextBoxFor
:
@Html.TextBoxFor(model => model.CreatedUser, new { @class = "form-control" ,@placeholder = "Your Placeholder Text" })
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)