Antarr Byrd
Antarr Byrd

Reputation: 26121

Overriding OnClientClick causing validation to fire multiple times

I'm trying to prevent a form from being submitted multiple time. It uses a validation summary so I am overriding the OnClientClick event for the submit button. It works as expected, the window showing the list of errors is being loaded multiple times.

<asp:Button ID="btnSubmit" runat="server" 
            Text="Submit" 
            CausesValidation="False" 
            ValidationGroup="vgApplication" 
            OnClientClick=" if ( Page_ClientValidate() ) { this.value='Submitting..'; this.disabled=true; }" 
  />

Upvotes: 0

Views: 304

Answers (1)

Antarr Byrd
Antarr Byrd

Reputation: 26121

The problem was that I have multiple ValidationGroups on my form. So I had to specify which ValdationGroup to run by passing in the name to Page_ClientValidate().

<asp:Button ID="btnSubmit" runat="server" 
            Text="Submit" 
            CausesValidation="False" 
            OnClientClick=" if ( Page_ClientValidate('vgApplication') ) { this.value='Submitting..'; this.disabled=true; }" 
  />

Upvotes: 1

Related Questions