This documentation is archived and is not being maintained.

ChangePassword.NewPasswordRequiredErrorMessage Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the error message that is displayed when the user leaves the New Password text box empty.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public virtual string NewPasswordRequiredErrorMessage { get; set; }
/** @property */
public String get_NewPasswordRequiredErrorMessage ()

/** @property */
public void set_NewPasswordRequiredErrorMessage (String value)

public function get NewPasswordRequiredErrorMessage () : String

public function set NewPasswordRequiredErrorMessage (value : String)

Property Value

The error message to display if the user leaves the New Password text box empty. The default is "New Password is required."

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 ASP.NET Globalization and Localization.

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.


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#"%>

<script runat="server">


<head runat="server">
  <title>Change Password with Validation</title>
  <form id="form1" runat="server">
  <asp:changepassword id="ChangePassword1" runat="server"
  PasswordHintText = 
    "Please enter a password at least 7 characters long, 
    containing a number and one special character."
  NewPasswordRegularExpression =
  NewPasswordRegularExpressionErrorMessage =
    "Error: Your password must be at least 7 characters long, 
    and contain at least one number and one special character." >

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0