Welcome to Bilal Haidar [MVP, MCT] Official Blog Sign in | Join | Help

Password TextBox and PostBack

Sometimes in an ASP.NET (1.x/2.x) webform, we might have a Password TextBox, and one of the DropDownLists or RadiobuttonLists or any control present inside the web form might do a postback before you need to submit the form.

Every time this happens, I loose the Password TextBox value. A solution that might help you preserve the Password Textbox value upon postback is to add the following line inside the Page_Load event handler, so that they execute AT EVERY PAGE EXECUTION:

// Refill Password field
this.txtPassword.Attributes.Add("value", this.txtPassword.Text);

Hope this helps,

Regards

Published Sunday, February 19, 2006 3:13 AM by BilalHaidar [MVP]

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Password TextBox and PostBack

yes,i do this usually.And i want to know if there are other methods? link bo888chuan@tom.com
Monday, May 22, 2006 2:21 AM by kele

# re: Password TextBox and PostBack

Great it works but it has to execute on Every Page Load else it will not work
Saturday, June 24, 2006 12:53 PM by Aashif

Leave a Comment

(required) 
required 
(required)