ASP.Net MVC3 Html.PasswordFor 不填充 [英] ASP.Net MVC3 Html.PasswordFor does not populate

查看:25
本文介绍了ASP.Net MVC3 Html.PasswordFor 不填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我有以下元素

In my view I have the following element

  @Html.PasswordFor(model => model.Password)

这是在创建/更新用户详细信息的屏幕上.当我尝试更新用户时,此字段保持空白.当我将此元素更改为 TextBoxFor 时,它会获取数据.如何填充密码字段.

This is on a screen that creates/updates user details. When I am trying to update the user this field remains blank. When I change this element to a TextBoxFor it gets the data. How do I get to populate the Password field.

推荐答案

这是设计好的.不填写密码是为了防止意外重新提交,并防止页面包含未加密的密码.如果您发回凭据,显然密码一开始就错误.

This is as designed. Passwords are not filled to prevent accidental resubmits, and to prevent the page from containing unencrypted passwords. Obviously the password was wrong to begin with if you're posting back the credentials.

在您的情况下,您可以创建一个输入数据的扩展程序,或者只使用密码类型的 HTML 输入.

In your case, you could create an extension that does input the data, or just use an HTML input of type password.

这篇关于ASP.Net MVC3 Html.PasswordFor 不填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆