Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password field blank after postback

Status
Not open for further replies.

WorkerBeeJ

Programmer
Aug 6, 2002
34
US
I found a similar post from last year with no resolution. Hoping someone else has a solution this time. I have a textbox on a form to allow the user to set the value of a password, so I'm using the textmode="password" attribute. On that same form are controls which fire postbacks (dropdowns with autopostback set to true). These postbacks are blanking out that password field. That field still has it's value on PreRender, so it looks like this is happening at some point after the PreRender of the page. Does anyone know how to prevent that password field from losing it's value after these postbacks.

Thanks,
J
 
To get around this you can set the password on postback.

For example, in the PreRender method read the value from the password box:

Code:
if(Page.IsPostBack)
{
_password = txtPassword.Text;
}

Then in the page load event:

Code:
if(Page.IsPostBack)
{
txtPassword.Attributes.Add("value", _password);
}

(been a while since i've done this so you might need to alter the syntax).

HTH

Smeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top