Create Password field @html.TextBoxFor
You can still use @Html.TextBoxFor:
@Html.TextBoxFor(model => model.Password, new {@class="form-control", placeholder="Password", @type = "password" })
I also got the same problem and already used the code below but I have no idea why it didn't work
@Html.EditorFor(model => model.Password, new { htmlAttributes = new {@class="form-control", placeholder="Password"}})
but then I found the solution that is to add type ="password"
into code above
then, the code is now
@Html.EditorFor(model => model.Password, new { htmlAttributes = new {@class="form-control", placeholder="Password", Type="password"}})
update I've found another way to fix that is that is just add data annotation to Password property in LoginViewModel
[DataType(DataType.Password)]
public String Password { get; set; }
and in the view page just type this code
@Html.EditorFor(model => model.Password, new { htmlAttributes = new {@class="form-control", placeholder="Password"}})
If your MVC version is new enough, then
@Html.EditorFor(model => model.Password, new { htmlAttributes = new {@class="form-control", placeholder="Password"}})
Otherwise
@Html.PasswordFor(model => model.Password, new {@class="form-control", placeholder="Password"})