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;
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
Post a Comment