0

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; }" 
  />
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
  • 1
    Well, trivially, since you run Page_ClientValidate() manually, this will cause the validation to happen a second time, in addition to the automated validation process. Try checking the boolean Page_IsValid instead. See https://msdn.microsoft.com/en-us/library/aa479045.aspx#aspplusvalid_clientside – ADyson Mar 07 '18 at 17:12
  • @ADyson I have CausesValidation set to False. – Antarr Byrd Mar 07 '18 at 17:48
  • try CausesValidation="false" ? – DaniDev Mar 07 '18 at 19:43
  • @AntarrByrd only since you edited the question, which is after I wrote that comment. – ADyson Mar 08 '18 at 06:46

1 Answers1

1

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; }" 
  />
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188