在我的项目登录表格中我必须实现默认显示,当我们点击文本框时,文本框必须为空白,反之亦然。这是我的代码
<li><i class="icon-user"></i>@Html.TextBoxFor(Model => Model.UserName, new { @class = "login-user-input", autocomplete = "off", @value="UserName"})</li>
<li><i class="icon-key"></i> @Html.TextBoxFor(Model => Model.Password, new { @class = "login-user-input", autocomplete = "off" })</li>
答案 0 :(得分:4)
您可以使用placeholder
属性
@Html.TextBoxFor(Model => Model.UserName,
new {
@class = "login-user-input",
autocomplete = "off",
placeholder="UserName"
})