asp.net.ph

Skip Navigation Links

ChangePassword Control Syntax

ASP.NET Syntax   ASP.NET Syntax for Web Controls


Creates a user interface that enables users to change their Web site password.

Declarative Syntax

For information on the individual members of this class, see ChangePassword in the class library.

Remarks

The ChangePassword control enables Web site users to change the passwords they use to log on to a Web site.

Security Note: Transmitting passwords over HTTP is a potential security vulnerability, as HTTP transmissions can be viewed or compromised by malicious users. To improve security when using login controls, you should use the HTTPS protocol with secure sockets layer (SSL) encryption to ensure that the user’s password cannot be read during postback.

The ChangePassword control uses the membership provider that is defined in the MembershipProvider property to change the password that is stored in the membership provider data store for the Web site. If you do not assign a membership provider, the ChangePassword control uses the default membership provider that is defined in the membership section of the Web.config file.

Syntax Example

The following example shows how to set the NewPasswordRegularExpression property to define a regular expression that checks passwords to ensure that they meet the following criteria:

  • Are greater than six characters.
  • Contain at least one digit.
  • Contain at least one special ( non-alphanumeric ) character.

The password requirements that are contained in the PasswordHintText property are displayed to the user.

If the password that is entered by the user does not meet the requirements of the NewPasswordRegularExpression property, the text that is contained in the NewPasswordRegularExpressionErrorMessage property is displayed to the user. If a new password is not entered, the text that is contained in the NewPasswordRequiredErrorMessage property is displayed to the user.

NOTE: The new password must meet the minimum requirements that are set by the membership provider in the MinRequiredPasswordLength, MinRequiredNonAlphanumericCharacters, and PasswordStrengthRegularExpression properties. If the password does not meet these requirements, the ChangePasswordError event is raised.

<asp:changepassword id="ChangePassword1" runat="server"
   PasswordHintText = "Please enter a password at least 7 characters long, 
      containing a number and one special character."
   NewPasswordRegularExpression =
      ’@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})’ 
   NewPasswordRegularExpressionErrorMessage =
      "Error: Your password must be at least 7 characters long, 
      and contain at least one number and one special character.">
</asp:changepassword>
See Also

ChangePassword Class   ChangePassword Web Server Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note