开发者

validation problem

I'm having a validation issue that I can't figure out. I "know" I have it set up correctly but everytime it does not stop me on submit. Basically, I have a form and the only thing required in the form is a textbox called "tbEmail". Here is the code from my aspx page:

<tr>
            <td>
                <asp:TextBox ID="tbEmail" runat="server" Height="40px" Width="688px" 
                    Font-Size="20px" input-type="email" CausesValidation="True" AutoCompleteType="Email"></asp:TextBox>
            </td>
            <td>
                <asp:RegularExpressionValidator ID="regexEmail" runat="server" ControlToValidate="tbEmail" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Email">
                </asp:RegularExpressionValidator>
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server"  ValidationGroup="Email" C开发者_Python百科ontrolToValidate="tbEmail" ErrorMessage="*">
                </asp:RequiredFieldValidator>
        </td>
        </tr>

In my code behind, on the image button click event handler I have this:

protected void btnSubscribe_Click(object sender, ImageClickEventArgs e)
    {

        Page.Validate("Email");
        if (Page.IsValid)
        {
                //call the method 

                my method here...

                mvwForm.SetActiveView(vwSuccessEmail);


                ClearControls(Page);


        }
        else
            {
                lblValidation.Visible = true;
            }


    }

but everytime, if I leave the e-mail field blank it proceeds to load the vwSuccessEmail view. I have tried setting the tbEmail control to use ValidationGroup="Email" as well with the same result. Anyone catch what I'm missing here?


I don't know if you already did it but you should set btnSubscribe to use ValidationGroup="Email" as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜