How to disable submit button when pressed?

Last post 10-25-2008 10:45 PM by mbanavige. 2 replies.

Sort Posts:

  • How to disable submit button when pressed?

    10-25-2008, 7:22 PM
    • Contributor
      3,346 point Contributor
    • WhatThe12
    • Member since 10-08-2003, 7:37 AM
    • Herts, UK
    • Posts 890

    Sounds easy right? Well no....

     A server side button's OnClientClick is no good because the form's validation runs after the code assigned to this property is run. This means that you don't know whether the form is actually submitting until its too late so there's no way to know whether to disable the button.

     The form's onSubmit is also no good because there's more asp.net framework code running there.

     Any ideas?

    Cheers, WT.

    Web dev - spending forever achieving nothing.
  • Re: How to disable submit button when pressed?

    10-25-2008, 10:19 PM
    Answer
    • Contributor
      3,346 point Contributor
    • WhatThe12
    • Member since 10-08-2003, 7:37 AM
    • Herts, UK
    • Posts 890

    Oh cool, assigning code to the form's 'onsubmit' attribute has asp.net add the code after all of its processing. There it only runs if the validation has succeeded.

    Web dev - spending forever achieving nothing.
  • Re: How to disable submit button when pressed?

    10-25-2008, 10:45 PM
    Answer
    • All-Star
      98,222 point All-Star
    • mbanavige
    • Member since 11-06-2003, 8:29 AM
    • New England, USA
    • Posts 10,355
    • Moderator
      TrustedFriends-MVPs
    Mike Banavige
    ~~~~~~~~~~~~
    Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
Page 1 of 1 (3 items)