How to get password html helper to render password on failed validation
I have a form for creating a new account and it has a password field in it. I'm using view models to pass data to the controller action and back to the form view. When the user enters their details in, and clicks submit, if validat开发者_StackOverflow中文版ion fails and it returns them to the same view passing back in the view model, it won't default the password to what they entered.
How can I get it to do this? Or should I even try?
You can set the password after validation by explicitly calling:
<%= Html.Password("Pwd", Model.Pwd) %>
As for motivation I've seen both behaviours in the web, but probably I would choose to leave the password empty and make the user retype the password, hence leaving the Password Helper behaviour as it is.
精彩评论