How can we retain password in Postback ?

Hi All,

Normally in programming we encounter a problem that whenever IsPostBack occurs then at that time if we used password field then the password field will clear.

Now I am representing the solution of the above problem that how can we retain the password.

See below code,

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        if (!(String.IsNullOrEmpty(txtPassword.Text.Trim())))
        {
            txtPassword.Attributes.Add("value",
            txtPassword.Text.ToString());
        }
    }
}