Monday 6 August 2007

ASP.NET - Save password value

If you create a textbox with a TextMode of Password, you will see that when the form is submitted, the value is lost out of the textbox. This is due to security reasons, but you can force it to keep the value by simply adding the following to the Page_LoadComplete event:



If Page.IsPostBack Then
Me.password.Attributes.Add("value", Me.password.Text)
End If



Just make sure you replace "password" with the name of your textbox.

No comments: