Export (0) Print
Expand All
Expand Minimize

CreateUserWizard.EmailRegularExpression Property

Gets or sets a regular expression used to validate the provided e-mail address.

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

public virtual string EmailRegularExpression { get; set; }
<asp:CreateUserWizard EmailRegularExpression="String" />

Property Value

Type: System.String
A string containing the regular expression used to validate an e-mail address. The default value is an empty string ("").

Use the EmailRegularExpression property to specify a regular expression that validates the e-mail address entered by the user to confirm that it matches a specific pattern. A common use is to make sure that the user has entered a complete e-mail address, such as user@contoso.com. The regular expression is used in addition to any restrictions placed on the e-mail address by the membership provider specified in the MembershipProvider property. If the membership provider rejects the e-mail address for any reason, the text contained in the InvalidEmailErrorMessage property is displayed.

The address is only compared to the regular expression if the RequireEmail property is set to true.

If the e-mail address does not pass the regular expression, the text contained in the EmailRegularExpressionErrorMessage property is displayed to the user.

The following code example assigns a regular expression to the EmailRegularExpression property to make sure that the user entered their e-mail address in a valid format, such as username@contoso.com.

<%@ 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>CreateUserWizard.EmailRegularExpression sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <asp:createuserwizard id="Createuserwizard1" runat="server" 
        emailregularexpression='@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"' 
        emailregularexpressionerrormessage="E-mail address must be in a valid format">
      </asp:createuserwizard>
    </div>
    </form>
</body>
</html>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft