ChangePassword.PasswordHintText Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets informational text about the requirements for creating a password for the Web site.
public:
virtual property System::String ^ PasswordHintText { System::String ^ get(); void set(System::String ^ value); };
public virtual string PasswordHintText { get; set; }
member this.PasswordHintText : string with get, set
Public Overridable Property PasswordHintText As String
Property Value
The informational text to display about the criteria for the new password. The default is Empty.
Examples
The following code 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 contained in the PasswordHintText property are displayed to the user.
If the password entered by the user does not meet the criteria, the text contained in the NewPasswordRegularExpressionErrorMessage property is displayed to the user. If a new password is not entered, the text contained in the NewPasswordRequiredErrorMessage property is displayed to the user.
Note
The new password must also meet the minimum requirements 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.
<%@ page language="C#"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Change Password with Validation</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<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>
</div>
</form>
</body>
</html>
<%@ page language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Change Password with Validation</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<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 = "Your password must be at least 7 characters long, and contain at least one number and one special character.">
</asp:changepassword>
</div>
</form>
</body>
</html>
Remarks
The PasswordHintText property gets or sets informational text about the requirements for creating a password for the Web site. Use this property to describe the requirements for the new password that are specified in the NewPasswordRegularExpression property.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and Globalization and Localization.
Applies to
See also
- NewPasswordRegularExpression
- PasswordHintStyle
- PasswordLabelText
- ASP.NET Login Controls Overview
- Customizing Appearance and Behavior of the ASP.NET Login Controls
- ASP.NET Web Server Controls Templates
- How to: Display Different Information to Anonymous and Logged In Users
- Web Site Administration Tool Security Tab