views:

126

answers:

1

Hi! I'm using ajax loader in my web page and password field. Whenever, the ajax is loading the password is getting reset often. I hav more than 8 fields which will call ajax, which will make the user to enter the password again and again. Is there any way to make the password constant without getting reset?

Thanks in Advance!!!!!

A: 

Sounds like you need to make the resources the ajax is requesting public so they don't require authentication.

When an HTML <input type="password".. element is rendered after a post back (even an ajax post) it will be empty. This is by design for security.

You can hack around the issue, but it leaves the users password in plain text in the HTML where it is vulnerable.

If the risk is considered low enough for your project this is how you get around it in ASP.NET in the Page_Load event handler:

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

If you do this though when retreiving the value use:

        string password = txtPassword.Attributes["value"];

Instead of:

        string password = txtPassword.Text;
HollyStyles
How to do that? Can u just post the code plz?
Nila
Code isn't the problem here. Is your password field inside the update panel?
HollyStyles
Password fields are always blanked out after an HTTP POST operation.
HollyStyles
Actually, I'm using the update panel in master page.. So, obviously, the password field is inside the update panel.
Nila
Well there you go then. I Have extended my answer, hope this helps.
HollyStyles