我创建了MVC5应用程序,当用户输入passowrd(显示星号)并且工作正常时,我在创建模式下使用以下代码。在显示模式下,我想只显示星号(不是空文本框)对于用户输入密码的字段,我应该怎么做?
这是创建
中的代码 <div class="form-group">
@Html.LabelFor(model => model.Password, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.Password("password", "", new { id = "password", Textmode = "Password" })
</div>
</div>
答案 0 :(得分:2)
您可以使用placeholder
属性:
<div class="form-group">
@Html.LabelFor(model => model.Password, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.Password("password", "", new { id = "password", placeholder = "***", Textmode = "Password" })
//or for displaying, just type
<label>*****</label>
</div>
</div>
答案 1 :(得分:1)
<div class="form-group">
@Html.LabelFor(model => model.Password, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.Password("password", "", new { id = "password", Textmode = "Password",value="something" })
</div>
</div>