Feb 19 2006

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

Tags: , ,

Comments are closed