ChangePassword.NewPasswordRequiredErrorMessage 属性
定义
获取或设置当用户将“新密码”文本框留空时显示的错误消息。Gets or sets the error message that is displayed when the user leaves the New Password text box empty.
public:
virtual property System::String ^ NewPasswordRequiredErrorMessage { System::String ^ get(); void set(System::String ^ value); };
public virtual string NewPasswordRequiredErrorMessage { get; set; }
member this.NewPasswordRequiredErrorMessage : string with get, set
Public Overridable Property NewPasswordRequiredErrorMessage As String
属性值
当用户将“新密码”文本框留空时显示的错误消息。The error message to display if the user leaves the New Password text box empty. 默认值为:必须填写新密码。The default is "New Password is required."
示例
下面的代码示例演示如何设置 NewPasswordRegularExpression 属性以定义用于检查密码的正则表达式,以确保它们符合以下条件: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:
超过6个字符。Are greater than six characters.
包含至少一个数字。Contain at least one digit.
包含至少一个特殊 (非字母数字) 字符。Contain at least one special (non-alphanumeric) character.
属性中包含的密码要求 PasswordHintText 将显示给用户。The password requirements contained in the PasswordHintText property are displayed to the user.
如果用户输入的密码不符合条件,则 NewPasswordRegularExpressionErrorMessage 会向用户显示该属性中包含的文本。If the password entered by the user does not meet the criteria, the text contained in the NewPasswordRegularExpressionErrorMessage property is displayed to the user. 如果未输入新密码,则 NewPasswordRequiredErrorMessage 会向用户显示该属性中包含的文本。If a new password is not entered, the text contained in the NewPasswordRequiredErrorMessage property is displayed to the user.
备注
新密码还必须满足、和属性中的 成员资格提供程序 所设置的最低要求 MinRequiredPasswordLength MinRequiredNonAlphanumericCharacters PasswordStrengthRegularExpression 。The new password must also meet the minimum requirements set by the membership provider in the MinRequiredPasswordLength, MinRequiredNonAlphanumericCharacters, and PasswordStrengthRegularExpression properties. 如果密码不符合这些要求,则 ChangePasswordError 会引发事件。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>
注解
设置此属性后,可以使用设计器工具自动将此属性的值保存到资源文件中。The value of this property, when set, can be saved automatically to a resource file by using a designer tool. 有关详细信息,请参阅 LocalizableAttribute 和 全球化和本地化。For more information, see LocalizableAttribute and Globalization and Localization.
适用于
另请参阅
- NewPassword
- NewPasswordRegularExpressionErrorMessage
- NewPasswordLabelText
- NewPasswordRegularExpression
- ASP.NET 登录控件概述ASP.NET Login Controls Overview
- 自定义 ASP.NET 登录控件的外观和行为Customizing Appearance and Behavior of the ASP.NET Login Controls
- ASP.NET Web 服务器控件模板ASP.NET Web Server Controls Templates
- 如何:向匿名用户和已登录的用户显示不同的信息How to: Display Different Information to Anonymous and Logged In Users
- 网站管理工具的 "安全" 选项卡Web Site Administration Tool Security Tab