输入无效的 MVC5 占位符
MVC5 placeholder for input not working
我的代码是这样的
@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;">
接受 htmlAttributes
的 EditorFor
重载仅是 MVC 5.1。
见HERE
如果无法升级,请使用 TextBoxFor
:
@Html.TextBoxFor(model => model.CreatedUser, new { @class = "form-control" ,@placeholder = "Your Placeholder Text" })
我的代码是这样的
@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;">
接受 htmlAttributes
的 EditorFor
重载仅是 MVC 5.1。
见HERE
如果无法升级,请使用 TextBoxFor
:
@Html.TextBoxFor(model => model.CreatedUser, new { @class = "form-control" ,@placeholder = "Your Placeholder Text" })