Disable Submit Button

Discussion in 'ASP .Net' started by Jeff, Oct 18, 2004.

  1. Jeff

    Jeff Guest

    I have a payment form with a submit button. A large percentage of users
    double-click the submit button thus submitting their payment information
    twice. I would like to use javascript to disable the submit button once
    it's been clicked, yet still have the form submit. I can do this in ASP
    2.0, however, ASP.Net seems to be adversely affected if you disable the
    submit button. Here's how I have it set up...

    The submit button is a WebControls.Button
    In the Page_Load event I attach an "onclick" javascript event handler to
    disable the submit button.

    i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
    = true; return true;")

    The problem with this is once the button is disable the form will not
    submit. If I change it to the following it will work, however, the button
    will not be disabled.

    i.e. btnSubmit.Attributes.Add("onclick", "document.Form1.btnSubmit.disabled
    = false; return true;")

    Any ideas on how to accomplish this?

    Thanks!
    Jeff, Oct 18, 2004
    #1
    1. Advertising

  2. Jeff

    David Wier Guest

    Check out this, in the Tips & Tricks section of http://aspnet101.com:
    http://aspnet101.com/aspnet101/tips.aspx?id=81

    David Wier
    MCP, MVP ASP.NET, ASPInsider
    http://aspnet101.com
    http://aspexpress.com


    "Jeff" <> wrote in message
    news:Osd$A%...
    > I have a payment form with a submit button. A large percentage of users
    > double-click the submit button thus submitting their payment information
    > twice. I would like to use javascript to disable the submit button once
    > it's been clicked, yet still have the form submit. I can do this in ASP
    > 2.0, however, ASP.Net seems to be adversely affected if you disable the
    > submit button. Here's how I have it set up...
    >
    > The submit button is a WebControls.Button
    > In the Page_Load event I attach an "onclick" javascript event handler to
    > disable the submit button.
    >
    > i.e. btnSubmit.Attributes.Add("onclick",

    "document.Form1.btnSubmit.disabled
    > = true; return true;")
    >
    > The problem with this is once the button is disable the form will not
    > submit. If I change it to the following it will work, however, the button
    > will not be disabled.
    >
    > i.e. btnSubmit.Attributes.Add("onclick",

    "document.Form1.btnSubmit.disabled
    > = false; return true;")
    >
    > Any ideas on how to accomplish this?
    >
    > Thanks!
    >
    >
    David Wier, Oct 18, 2004
    #2
    1. Advertising

  3. Jeff

    bruce barker Guest

    btnSubmit.Attributes.Add("onclick",
    "window.setTimeout('document.Form1.btnSubmit.disabled= true;',10);");

    but this recommend. the submit fails (post lost on internet), the user can
    not refire it. if they hit refresh, the button will be enabled. you should
    store a transaction guid in a hidden field and tack that it has been
    processed. you should also code for two running at the same time.

    -- bruce (sqlwork.com)


    "Jeff" <> wrote in message
    news:Osd$A%...
    > I have a payment form with a submit button. A large percentage of users
    > double-click the submit button thus submitting their payment information
    > twice. I would like to use javascript to disable the submit button once
    > it's been clicked, yet still have the form submit. I can do this in ASP
    > 2.0, however, ASP.Net seems to be adversely affected if you disable the
    > submit button. Here's how I have it set up...
    >
    > The submit button is a WebControls.Button
    > In the Page_Load event I attach an "onclick" javascript event handler to
    > disable the submit button.
    >
    > i.e. btnSubmit.Attributes.Add("onclick",

    "document.Form1.btnSubmit.disabled
    > = true; return true;")
    >
    > The problem with this is once the button is disable the form will not
    > submit. If I change it to the following it will work, however, the button
    > will not be disabled.
    >
    > i.e. btnSubmit.Attributes.Add("onclick",

    "document.Form1.btnSubmit.disabled
    > = false; return true;")
    >
    > Any ideas on how to accomplish this?
    >
    > Thanks!
    >
    >
    bruce barker, Oct 18, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Brett
    Replies:
    4
    Views:
    11,719
    James Brett
    Nov 26, 2003
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,203
    Ghafran Abbas
    Oct 12, 2004
  3. jack-e

    Disable Submit Button

    jack-e, Jun 20, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    4,194
    Eliyahu Goldin
    Jun 20, 2005
  4. Paul Oakfleet
    Replies:
    1
    Views:
    845
    Chris Riesbeck
    Sep 10, 2003
  5. Chuck
    Replies:
    0
    Views:
    257
    Chuck
    Nov 10, 2003
Loading...

Share This Page