aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

keep-maintain password textbox value during postback

Jul 26, 2012

In this article I will explain how to keep or maintain text of password textbox during postback in

In previous posts I explained many articles relating to, JQuery, and SQL etc. Now I will explain how to maintain text of password textbox during postbacks in Generally if you observer password textbox it won’t maintain text if any postback happens like as shown below

If we want to maintain text of password textbox we need to write some code in pageload event for that first write the following code in your aspx page

<html xmlns="">
<head runat="server">
<title>Maintain Password textbox data in postback</title>
<form id="form1" runat="server">
<td><asp:TextBox ID="txtUserName" runat="server"/></td>
<td><asp:TextBox ID="txtPwd" runat="server" TextMode="Password"/></td>
<td><asp:Button ID="btnSubmit" runat="server" Text="Submit" /></td>
After completion of aspx page design write the following code in pageload event like as shown below

C# code

protected void Page_Load(object sender, EventArgs e)
string pwd = txtPwd.Text;
txtPwd.Attributes.Add("value", pwd);

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim pwd As String = txtPwd.Text
txtPwd.Attributes.Add("value", pwd)
End Sub

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Just remember that, in that way, the value is visible in the page cource.

Anonymous said...

but for me password field is showing empty ....and trying to bind password from cookies and store that in a html textbox

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.