views:

59

answers:

1

I have a text box that is intended for an Email address. I am using a Regular eExppression validation control to validate the email address.

When I place the following lines of code in a blank web Form, the validator works properly.

<asp:TextBox ID="Email" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="80"></asp:TextBox>

<asp:RegularExpressionValidator ID="valEmail" runat="server" ControlToValidate="Email" ErrorMessage="Invalid Email address" SetFocusOnError="True" ToolTip="Invalid Email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator`>

However, when I use the validation control within a CreateUserWizard control, it does not seem to fire but other validation controls (Required and Custom validators) do fire, but not the regular expression validator above for validating the address.

The following is my complete web page. The two controls above appear unchanged in the code below, they are simply embedded into the wizard control mentioned.

<%@ Page Title="" Language="VB" MasterPageFile="~/Master Pages/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>

<%@ MasterType VirtualPath="~/Master Pages/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        .TextboxWidth
        {
            width: 200px;
        }
        .Heading
        {
            font-weight: bold;
            font-size: 12pt;
            color: rgb(44, 68, 105);
        }
        .StdFrameWidth
        {
            width: 350px;
        }
        .StdTableWidth
        {
            width: 750px;
        }                

    </style>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="phPageContent" runat="Server">
    <div style="margin-left: 10px; margin-top: 30px;">
        <h1 style="text-align: left;">
            Affiliate Program</h1>
        <div class="LightText">
        </div>
        <hr />
        <asp:ValidationSummary ID="ValidationSummary2" runat="server" ValidationGroup="Login1" />
    </div>
    <table class="StdTableWidth">
        <tr>
            <td style="padding-top: 10px; padding-left: 20px; padding-right: 20px; vertical-align: top;">
                <div>
                    <div>
                        Some General high-level bullshit about the Affiliate program.</div>
                </div>
            </td>
            <td>
                <fieldset>
                    <legend class="StdFrameWidth StdLegend">Already an Affiliate?</legend>
                    <asp:Login ID="Login1" runat="server" CreateUserText="Register" DestinationPageUrl="~/Secure/AffiliateDefault.aspx" FailureText="Unsuccessful login. Please try again.">
                        <LayoutTemplate>
                            <table cellpadding="2" cellspacing="2" style="border-collapse: collapse; margin-top: 15px;">
                                <colgroup>
                                </colgroup>
                                <tr>
                                    <td align="right" style="white-space: nowrap;">
                                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" CssClass="LightText">User Name:</asp:Label>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="UserName" runat="server" CssClass="DefaultTextBox  TextboxWidth"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">Required</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">
                                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" CssClass="LightText">Password:</asp:Label>
                                    </td>
                                    <td>
                                        <asp:TextBox ID="Password" runat="server" CssClass="DefaultTextBox  TextboxWidth" TextMode="Password"></asp:TextBox>
                                    </td>
                                    <td>
                                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1" SetFocusOnError="True">Required</asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <td>
                                    </td>
                                    <tr>
                                        <td colspan="2" style="text-align: right;">
                                            <asp:CheckBox ID="RememberMe" runat="server" CssClass="LightText" Text="Remember me next time." />
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" colspan="2" style="color: Red;">
                                            <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                        </td>
                                        <td align="center" style="color: Red;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right" colspan="2">
                                            <asp:Button ID="LoginButton" runat="server" CommandName="Login" OnPreRender="LoginButton_PreRender" Text="Log In" ValidationGroup="Login1" />
                                        </td>
                                        <td align="right">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </tr>
                            </table>
                        </LayoutTemplate>
                    </asp:Login>
                </fieldset>
            </td>
        </tr>
    </table>
    <table bgcolor="#F7F7F7" class="StdTableWidth">
        <tr>
            <td style="padding-top: 10px; padding-left: 20px; padding-right: 20px; vertical-align: top;">
                <div>
                    <div class="Heading">
                        Heading
                    </div>
                    <div>
                        Body dk dfljdsf lksdjf ldskfj dslkfj sdlfkjds flkjsdf lksdjf lsdkfj sdlfkj sdlfkjsd flkjsd flkdsjf lkdsjf lksdjf lsdkjf dslfkj sdlfkjs dlfkjdsf
                    </div>
                    <div class="Heading" style="margin-top: 20px;">
                        Heading
                    </div>
                    <div>
                        Body dk dfljdsf lksdjf ldskfj dslkfj sdlfkjds flkjsdf lksdjf lsdkfj sdlfkj sdlfkjsd flkjsd flkdsjf lkdsjf lksdjf lsdkjf dslfkj sdlfkjs dlfkjdsf
                    </div>
                </div>
            </td>
            <td style="vertical-align: top;">
                <fieldset style="background-color: #FFFFFF;">
                    <legend class="StdFrameWidth StdLegend">Affiliate Program Registration</legend>
                    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" Style="margin-top: 10px;" CreateUserButtonText="Register" ContinueDestinationPageUrl="~/Secure/AffiliateDefault.aspx" BorderColor="Gray" BorderStyle="None" CellPadding="5">
                        <SideBarTemplate>
                            Sidebar template
                        </SideBarTemplate>
                        <CreateUserButtonStyle CssClass="RegisterButtonClass" />
                        <WizardSteps>
                            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                                <ContentTemplate>
                                    <table border="0" cellpadding="2" cellspacing="2">
                                        <colgroup>
                                            <col width="150px" />
                                            <col width="150px" />
                                            <col />
                                        </colgroup>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" CssClass="DefaultLabelCaption">Create User Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="UserName" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="25"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" CssClass="DefaultLabelCaption">Password:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Password" runat="server" CssClass="DefaultTextBox TextboxWidth" TextMode="Password"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" Display="Dynamic" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword" CssClass="DefaultLabelCaption">Confirm Password:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="DefaultTextBox TextboxWidth" TextMode="Password" MaxLength="25"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                                <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." SetFocusOnError="True" ValidationGroup="CreateUserWizard1">*</asp:CompareValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="EmailLabel0" runat="server" AssociatedControlID="txtFirstName" CssClass="DefaultLabelCaption">First Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtFirstName" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="25"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="txtFirstName" Display="Dynamic" ErrorMessage="First Name is required." ToolTip="First Name is required" ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="EmailLabel1" runat="server" AssociatedControlID="txtLastName" CssClass="DefaultLabelCaption">Last Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtLastName" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="30"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="LastNameRequired" runat="server" ControlToValidate="txtLastName" Display="Dynamic" ErrorMessage="Last Name is required." ToolTip="Last Name is required." ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email" CssClass="DefaultLabelCaption">E-mail:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Email" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="80"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" Display="Dynamic" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator ID="valEmail" runat="server" ControlToValidate="Email" ErrorMessage="Invalid Email address" SetFocusOnError="True" ToolTip="Invalid Email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="CompanyLabel" runat="server" AssociatedControlID="txtCompanyName" CssClass="DefaultLabelCaption">Company Name:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtCompanyName" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="80"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="CompanyNameRequired" runat="server" ControlToValidate="txtCompanyName" Display="Dynamic" ErrorMessage="Company Name is required." SetFocusOnError="True" ToolTip="Company Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="AnswerLabel0" runat="server" AssociatedControlID="Answer" CssClass="DefaultLabelCaption">Website URL:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtWebsiteUrl" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="256"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="WebsiteUrlRequired" runat="server" ControlToValidate="txtWebsiteUrl" Display="Dynamic" ErrorMessage="Website URL is required." SetFocusOnError="True" ToolTip="Company Website URL is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                <asp:CustomValidator ID="cvalWebsiteUrl" runat="server" ControlToValidate="txtWebsiteUrl" ErrorMessage="Company Website URL has already been registered." onservervalidate="cvalWebsiteUrl_ServerValidate" SetFocusOnError="True" ToolTip="Company Website URL has already been registered." ValidationGroup="CreateUserWizard1">*</asp:CustomValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="TaxIdLabel" runat="server" AssociatedControlID="txtTaxId" CssClass="DefaultLabelCaption">Tax ID:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtTaxId" runat="server" CssClass="DefaultTextBox TextboxWidth" MaxLength="30"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:RequiredFieldValidator ID="TaxIdRequired" runat="server" ControlToValidate="txtTaxId" Display="Dynamic" ErrorMessage="Tax ID is required." SetFocusOnError="True" ToolTip="Tax ID is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                                <asp:CustomValidator ID="cvalTaxId" runat="server" ErrorMessage="Tax ID has already been registered." onservervalidate="cvalTaxId_ServerValidate" ControlToValidate="txtTaxId" SetFocusOnError="True" ValidationGroup="CreateUserWizard1" >*</asp:CustomValidator>
                                            </td>
                                        </tr>
                                        <tr style="display: none;">
                                            <td align="right">
                                                <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question" CssClass="DefaultLabelCaption">Security Question:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Question" runat="server" CssClass="DefaultTextBox TextboxWidth"></asp:TextBox>
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr style="display: none;">
                                            <td align="right">
                                                <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer" CssClass="DefaultLabelCaption">Security Answer:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Answer" runat="server" CssClass="DefaultTextBox TextboxWidth"></asp:TextBox>
                                            </td>
                                            <td>
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2">
                                                &nbsp;
                                                </td>
                                            <td align="center">
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" style="color: Red;">
                                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="CreateUserWizard1" />
                                            </td>
                                            <td align="center" style="color: Red;">
                                                &nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:CreateUserWizardStep>
                            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                                <ContentTemplate>
                                    <table border="0">
                                        <tr>
                                            <td align="center">
                                                Complete
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Your account has been successfully created.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Button ID="ContinueButton" runat="server" CausesValidation="False" CommandName="Continue" Text="Continue" ValidationGroup="CreateUserWizard1" OnPreRender="StepNextButton_PreRender" />
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:CompleteWizardStep>
                        </WizardSteps>
                    </asp:CreateUserWizard>
                </fieldset>
            </td>
        </tr>
    </table>
</asp:Content>

Why would only this validation stop working?

+2  A: 

Change the validation group top match that used by other validation controls in the wizard: "CreateUserWizard1"

Chad