How to maintain the password textbox text after postback

How to maintain the password textbox text after postback

In Asp.net the password textbox will not remain the value after postback so for that we can use this steps
to maintain the values.

The Coding As follows.

In the design page

<asp:textbox onprerender=”txtPassword_PreRender” id=”txtPassword” text=”abcd” maxlength=”25″ cssclass=”TextBox” width=”150px” runat=”server” textmode=”Password”></asp:textbox>

<asp:button onclick=”btnSubmit_Click” id=”btnSubmit” runat=”server” text=”Submit”/>

In the Code behind page

protected void txtPassword_PreRender(object sender, EventArgs e)
{
txtPassword.Attributes[“value”] = txtPassword.Text;
}

protected void btnSubmit_Click(object sender, EventArgs e)
{

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s