<%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Page</title> <script runat="server"> public string Password { get { return ViewState["Password"] as string; } set { this.ViewState["Password"] = value; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.IsPostBack) { if (!string.IsNullOrEmpty(this.txtPassword.Text)) this.Password = this.txtPassword.Text; this.txtPassword.Attributes.Add("value", this.Password ?? string.Empty); } } </script> </head> <body> <form id="aspNetForm" runat="server"> UserName: <asp:TextBox runat="server" ID="txtName" /> Password: <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" /> <hr /> <asp:Button runat="server" ID="btnSave" Text="Save" /> </form> </body> </html>
Wednesday, December 14, 2011
How to retain the password in a postback
Subscribe to:
Post Comments (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...
1 comment:
There is no need to override OnLoad Event. you can put the same code in Page_Load Event
Post a Comment