How to maintain password textbox value during postback asp.net

Retain the Password textbox value during postback:

In Page load add the following code:

if (Ispostback)
{

if (!(String.IsNullOrEmpty(txtUserPassword.Text.Trim())) && !(String.IsNullOrEmpty(txtReTypePassword.Text.Trim())))
 {
        txtUserPassword.Attributes["value"] = txtUserPassword.Text.Trim();
        txtReTypePassword.Attributes["value"] = txtReTypePassword.Text.Trim();
  }


}


You can also clear the Password text box  by setting the value empty :


  txtUserPassword.Attributes["value"] = string.Empty;
   txtReTypePassword.Attributes["value"] = string.Empty;


Comments

Popular posts from this blog

How to retain the data annotations or class during modify a table in the database

Interview Questions

AJAX CONTROL