Export (0) Print
Expand All
Expand Minimize
1 out of 4 rated this helpful - Rate this topic

CreateUserWizard.PasswordRegularExpression Property

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

Gets or sets a regular expression used to validate the provided password.

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

public virtual string PasswordRegularExpression { get; set; }
/** @property */
public String get_PasswordRegularExpression ()

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

public function get PasswordRegularExpression () : String

public function set PasswordRegularExpression (value : String)

Property Value

A string containing the regular expression used to validate the provided password. The default value is an empty string ("").

Use the PasswordRegularExpression property to define the requirements for passwords used to validate users on your Web site. A common use is to make sure that a user has included symbols other than letters in a password to make it harder for attackers to guess a password. The regular expression is used in addition to any restrictions placed on the password by the membership provider specified in the MembershipProvider property. If the membership provider rejects the password for any reason, the text contained in the InvalidPasswordErrorMessage property is displayed.

If the password entered does not pass the regular expression, the error message contained in the PasswordRegularExpressionErrorMessage property is displayed to the user.

The following code example uses the PasswordRegularExpression property to define a regular expression that checks passwords to ensure that they:

  • Are longer than seven characters.

  • Contain at least one digit.

  • Contain at least one special (nonalphanumeric) character.

If the password entered by the user does not meet these criteria, the text contained in the PasswordRegularExpressionErrorMessage property is displayed to the user.

<%@ page language="C#"%>

<script runat="server">

</script>

<html>
<head runat="server">
    <title>CreateUserWizard.PasswordRegularExpression sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:createuserwizard id="Createuserwizard1" runat="server" 
        passwordregularexpression='@\"(?=.{7,})(?=(.*\d){1,})(?=(.*\W){1,})'
        passwordregularexpressionerrormessage="Your password must be 7 characters long, and contain at least one number and one special character.">
      </asp:createuserwizard>
    </div>
    </form>
</body>
</html>

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.