I have a model CredencialesViewModel
which has a property Pwd
type string
add the decorator type data, but in the view does not render a input type password
if not that one type text. / p>
Why will this be?
I have a model CredencialesViewModel
which has a property Pwd
type string
add the decorator type data, but in the view does not render a input type password
if not that one type text. / p>
Why will this be?
If you define the ViewModel
in the following way
[Required(ErrorMessage = "Pass word is required")]
[DataType(DataType.Password)]
public string Password { get; set; }
According to your MVC version, if it's newer, you should, just use @EditorFor()
.
@Html.EditorFor(model => model.Password, new { htmlAttributes = new {@class="form-control", placeholder="Password"}})
and in case it's a little older
@Html.PasswordFor(model => model.Password, new {@class="form-control", placeholder="Password"})
This response is based on this StackOverflow publication in English.
Greetings and successes!