How to avoid press button again

Discussion in 'ASP .Net' started by ad, Aug 26, 2005.

  1. ad

    ad Guest

    I write a time-consuming process in a button's onclick event.
    Some user may press the button again when the process is excuting.
    How to avoid that?
    ad, Aug 26, 2005
    #1
    1. Advertising

  2. ad

    Arjen Guest

    Hi,

    Add this javascript:
    <script type="text/javascript" language="javascript">
    var submitted = 0;
    function check_double_click(form) {
    if (submitted == 1) {
    alert("Hey, don't press again! Fool!!!");
    return false;
    }
    submitted = 1;
    return true;
    }
    </script>

    Add this in your button
    OnClientClick="check_double_click(this)"

    Hope this helps,
    Arjen



    "ad" <> schreef in bericht
    news:%...
    >I write a time-consuming process in a button's onclick event.
    > Some user may press the button again when the process is excuting.
    > How to avoid that?
    >
    Arjen, Aug 26, 2005
    #2
    1. Advertising

  3. Hi,

    The simplest way is to add absolutely positioned div layer with a message
    like “Your request is being processed†and show them when the request is
    being processed. You can also hide processing button after user has clicked
    it. See javascript/CSS reference for “visibility†and “disabledâ€. Please also
    have a look at “onserverclick†“onclick†events for HtmlInputButton.

    Regards

    Milosz Skalecki

    MCP, MCAD


    "ad" wrote:

    > I write a time-consuming process in a button's onclick event.
    > Some user may press the button again when the process is excuting.
    > How to avoid that?
    >
    >
    >
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=, Aug 26, 2005
    #3
  4. ad

    Guest

    another simple method that works is to just disable the button onclick
    ....

    function Button_click(objButton)
    {
    objButton.disabled = true;
    return true;
    }

    add event
    onclick=Button_click(this);
    , Aug 26, 2005
    #4
  5. ad

    jasonkester Guest

    Note that these will only work on a browser with javascript enabled,
    and in the case of the parent, only in IE. Unless you have complete
    control over your user environment (i.e., intranet), you'll want to add
    code on the server side to make sure that the inevitable multiple
    submits get handled gracefully.

    Unfortunately, the most common place that this issue comes up is the
    one where you'll have the least control over your user's environment,
    that being the Checkout button in an ecommerce application. In this
    case, you'll also need to handle multiple submits on the server side
    too, if only as a fallback for the odd user coming in on IE 3 for the
    Macintosh, with Javascript disabled.

    Jason Kester
    Expat Software Consulting Services
    http://www.expatsoftware.com/
    jasonkester, Aug 26, 2005
    #5
    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. Jie
    Replies:
    7
    Views:
    6,125
    Xavier Pacheco
    Oct 9, 2004
  2. Alexander Malkis
    Replies:
    8
    Views:
    507
    Alexander Malkis
    Apr 14, 2004
  3. Johan Svedberg

    Avoid having to press Enter

    Johan Svedberg, Oct 10, 2003, in forum: C Programming
    Replies:
    6
    Views:
    440
  4. Roger23
    Replies:
    2
    Views:
    984
    Roger23
    Oct 12, 2006
  5. Max2006
    Replies:
    2
    Views:
    1,552
    Walter Wang [MSFT]
    Sep 19, 2007
Loading...

Share This Page