开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜