回发后清除密码字段 [英] Password field is cleared after postback

查看:92
本文介绍了回发后清除密码字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在开发一个C#asp.net应用程序。

我有一个包含2个下拉菜单和一个带有

type =" password" ;.

On" SelectedIndexChanged"第一次下拉的事件,有一个回发,

,以便根据在

第一个下拉列表中选择的值填充第二个下拉列表。

问题是之前填写过的密码字段在回发后被清除了



我知道这是为了安全,但有没有办法保持密码??


谢谢

Hello,

I am developing a C# asp.net application.
I have a webform which contains 2 dropdowns and a textbox with
type="password".
On "SelectedIndexChanged" event of the first dropdown, there is a postback,
in order to fill the second dropdown according to the value selected in the
first dropdown.
The problem is that the password field which has been filled up before is
cleared after postback.
I know this is for security, but is there a way to keep the password??

Thank you

推荐答案

dana lees写道:
dana lees wrote:
您好,

我正在开发一个C#asp.net应用程序。
我有一个webform,其中包含2个下拉列表和一个带有
type =" password"的文本框;。
On" SelectedIndexChanged"第一次下拉的事件,有一个
回发,以便根据第一个下拉列表中选择的值填充第二个下拉列表。
问题是密码字段已经被之前已经填满了回复后清除。
我知道这是为了安全,但有没有办法保存密码?

谢谢
Hello,

I am developing a C# asp.net application.
I have a webform which contains 2 dropdowns and a textbox with
type="password".
On "SelectedIndexChanged" event of the first dropdown, there is a
postback, in order to fill the second dropdown according to the value
selected in the first dropdown.
The problem is that the password field which has been filled up before is
cleared after postback.
I know this is for security, but is there a way to keep the password??

Thank you




是的,您可以添加值 postback上的密码文本框属性:


txtPassword.Attributes.Add(" value",txtPassword.Text)

Ben



Yes, you can add a "value" attribute to the password textbox on postback:

txtPassword.Attributes.Add("value", txtPassword.Text)

Ben


我试过了,但它没有用。这个领域空无一人......


Ben Amada < be*@REpoMOweVErpick.com>写在消息

新闻:Oa ************** @ TK2MSFTNGP12.phx.gbl ...
I have tried that and it didn''t work. The field stayed empty...

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
dana lees写道:
dana lees wrote:
你好,

我正在开发一个C#asp.net应用程序。
我有一个webform,包含2个下拉列表和一个带有
type =" password"。
On" SelectedIndexChanged"第一次下拉的事件,有一个
回发,以便根据第一个下拉列表中选择的值填充第二个下拉列表。
问题是密码字段已经被在回发后
被清除之前已经填满。
我知道这是为了安全,但有没有办法保存密码?

谢谢
Hello,

I am developing a C# asp.net application.
I have a webform which contains 2 dropdowns and a textbox with
type="password".
On "SelectedIndexChanged" event of the first dropdown, there is a
postback, in order to fill the second dropdown according to the value
selected in the first dropdown.
The problem is that the password field which has been filled up before is cleared after postback.
I know this is for security, but is there a way to keep the password??

Thank you



是的,您可以添加值 postback上的密码文本框属性:

txtPassword.Attributes.Add(" value",txtPassword.Text)




Yes, you can add a "value" attribute to the password textbox on postback:

txtPassword.Attributes.Add("value", txtPassword.Text)

Ben



dana lees写道:
dana lees wrote:
我试过了,它没有用。这个领域一直空着......
I have tried that and it didn''t work. The field stayed empty...




嗯......不知道为什么那不起作用。你使用的是.NET v2.0吗?我已经在v1.1中完成了

而没有任何问题。


另一种选择是通过

JavaScript。有几种方法可以做到这一点。


一种方法是创建一个隐藏的输入字段。在回发时,将密码放在

隐藏的输入字段中(即txtHiddenPwd.Value = txtPwd.Text)。然后使用

启动脚本或通过body标签的onload属性,将

密码文本框的值设置为隐藏输入字段的值。 />

Ben



Hmm... not sure why that doesn''t work. Are you using .NET v2.0? I''ve done
it in v1.1 without any problems.

Another option is to manually set the value of the password field via
JavaScript. There are several ways to do this.

One way is to create a hidden input field. On postback, put the password in
the hidden input field (i.e. txtHiddenPwd.Value = txtPwd.Text). Then with a
startup script or via the body tag''s onload attribute, set the value of the
password textbox to the value of the hidden input field.

Ben


这篇关于回发后清除密码字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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