Limiting User Clicks

Discussion in 'ASP .Net' started by Elroyskimms, May 16, 2005.

  1. Elroyskimms

    Elroyskimms Guest

    This may sound like a stupid question. Perhaps there is a simple answer
    that I am overlooking.

    I need some method of preventing the user from clicking the submit
    button multiple times that is supported across various browser
    platforms. I've tried everything I can think short of a wi-fi enabled
    electric shock collar for stupid user training.

    DETAILS:
    I have a web application that processes information submitted via a
    form. The entire process takes a couple of seconds, and no matter how
    many times I tell the user to "only click the submit button once", at
    least 10% of the users still double-click the button because they don't
    know the difference between a desktop icon and a web button. Or, they
    are impatient and can't wait the 3 or 4 seconds it takes for the
    processing to complete.
     
    Elroyskimms, May 16, 2005
    #1
    1. Advertising

  2. Elroyskimms

    Milsnips Guest

    why dont you put an Onclick event on the button and change button to
    disabled (via javascript) and maybe the text of the button to "please
    wait..." ?

    regards,
    Paul
    "Elroyskimms" <> wrote in message
    news:...
    > This may sound like a stupid question. Perhaps there is a simple answer
    > that I am overlooking.
    >
    > I need some method of preventing the user from clicking the submit
    > button multiple times that is supported across various browser
    > platforms. I've tried everything I can think short of a wi-fi enabled
    > electric shock collar for stupid user training.
    >
    > DETAILS:
    > I have a web application that processes information submitted via a
    > form. The entire process takes a couple of seconds, and no matter how
    > many times I tell the user to "only click the submit button once", at
    > least 10% of the users still double-click the button because they don't
    > know the difference between a desktop icon and a web button. Or, they
    > are impatient and can't wait the 3 or 4 seconds it takes for the
    > processing to complete.
    >
     
    Milsnips, May 16, 2005
    #2
    1. Advertising

  3. Elroyskimms

    Elroyskimms Guest

    Using server side scripting, the postback takes too long to prevent the
    user from "double clicking" the button, like they do a Windows icon.

    I read somewhere that client side Javascript usedto disable a button
    only works in IE. Is that true?
     
    Elroyskimms, May 16, 2005
    #3
  4. Disabling any type of client-side intrinsic functionality is generally a bad
    idea, not to mention an exercise in futility. Handling it is much better.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Sometimes you eat the elephant.
    Sometimes the elephant eats you.

    "Elroyskimms" <> wrote in message
    news:...
    > Using server side scripting, the postback takes too long to prevent the
    > user from "double clicking" the button, like they do a Windows icon.
    >
    > I read somewhere that client side Javascript usedto disable a button
    > only works in IE. Is that true?
    >
     
    Kevin Spencer, May 16, 2005
    #4
  5. Elroyskimms

    Eitan Guest

    I hope the following code will help.

    In page_load event do :

    (btnNew is the related button).
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    Dim btn As HtmlInputButton;

    btn = CType(btnNew, HtmlInputButton)

    btn.Attributes.Add("onclick", _

    String.Format("domyfunc();"))

    If (Not IsPostBack) Then

    ....

    end if

    end sub


    and in the html code of aspx :

    ....
    <script>

    function domyfunc()
    { var btn;
    btn = document.getElementById("btnNew");
    btn.disabled = true; // remember this line, that users could not click
    twice on the button very fast.
    alert("do something"); // do something of your own
    btn.disabled = false; // remember this line
    }

    </script>

    ....
    Know that every ASPx is basically HTML (but not vice versa).
    Think that ASPx writes always the code behind.
    When - when doing page_load.

    The sample is on page load (before clicking any button), so time here is no
    consuming (the event was calculated before you even see the page on the
    client).

    I am newbie in .NET, and I am asking this newsgroup also,
    but I think this code is fine ,after I tested it.

    Cheers :)
     
    Eitan, Jun 4, 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. Guest
    Replies:
    1
    Views:
    419
    Michael Pearson
    Oct 30, 2003
  2. Dave Taylor

    Limiting access to user files

    Dave Taylor, Apr 2, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    380
    Kevin Spencer
    Apr 2, 2004
  3. Arjun
    Replies:
    28
    Views:
    736
    al jones
    Jul 4, 2007
  4. PontiMax

    Clicks and double-clicks

    PontiMax, Jul 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    191
    Eliyahu Goldin
    Jul 14, 2004
  5. Paulo

    Doubt limiting user size upload

    Paulo, Apr 10, 2007, in forum: ASP General
    Replies:
    1
    Views:
    107
    Paulo
    Apr 11, 2007
Loading...

Share This Page