Reputation: 1337
I've created MVC5 app and I use the following code in create mode when user type passowrd(show asterisks ) and Its working fine .In display mode I want to display just the asterisks (not empty text box) for the field which the user type password ,how should I do that?
this is the code in the create
<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>
Upvotes: 3
Views: 3213
Reputation: 671
PasswordFor works real well.
@Html.PasswordFor(model => model.xxxPublicAPI, new { @class = "form-control", value = Model.xxxPublicAPI })
The @class is for style, but the value = Model.xxxPublicAPI is critical.
Upvotes: 0
Reputation: 3787
You can use placeholder
attribute:
<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>
Upvotes: 2
Reputation: 8184
<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>
Upvotes: 1