views:

41

answers:

2

I'm having some problems with my ASP.NET 4 application in Chrome & Safari (works in Firefox and IE).

I have a button declared using the following code:

<asp:Button ID="btnEOI1" runat="server" CssClass="buttonCSS" Text="Lodge an Expression of Interest"
                        OnClick="btnEOI_Click" CausesValidation="False" />

In the code-behind file I have the following code:

protected void btnEOI_Click(object sender, EventArgs e)
{
   Response.Redirect("Default.aspx", true);
}

Also on the page is a LoginControl that has two RequiredFieldValidators and a RegularExpressionValidator:

<asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" 
    ErrorMessage="Please enter your User Name." SetFocusOnError="true" Display="None">
</asp:requiredfieldvalidator>

<asp:RegularExpressionValidator runat="server" id="RegularExpressionValidator1"  
    ControlToValidate="UserName"
    ErrorMessage="Please enter your User Name without spaces." ValidationExpression="[\S]+" 
    Display="None" SetFocusOnError="true" >
</asp:RegularExpressionValidator>                                 

<asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" 
    ErrorMessage="Please enter your Password." SetFocusOnError="true" Display="None">
</asp:requiredfieldvalidator>

When I click the button in Chrome and Safari, the UserNameRequired and PasswordRequired validators fire even though the button has CausesValidation="false". The validation errors do not occur in IE or Firefox.

How can I stop the validators from firing in Chrome and Firefox?

+1  A: 

I have just tested your code in an empty page and it works correctly in all browsers.

Nervetheless you could try using Validation Groups.

Just set the same group for UserNameRequired, RegularExpressionValidator1, PasswordRequired and your login button.

Monika
Sorry for the delay - putting all of the validators into a Validation Group did not resolve the problem.
Anthony
A: 

It turns out that we had some javascript used to prevent double-clicking that was submitting form[0] (which in this case is the login control).

Anthony