Preventing multiple form submissions (multiple postbacks)

Discussion in 'ASP .Net' started by Diane Selby, Jun 24, 2004.

  1. Diane Selby

    Diane Selby Guest

    Hi-

    I am developing an ASP.NET application that can take a few seconds to
    process the request from the user. We are looking for a client-side
    solution that will prevent users from resubmitting the page multiple
    time in their irrational impatience.

    There are a few posts on this group which suggest that we use
    JavaScript hooked up to the page's OnSubmit event to catch mulitple
    submissions. See postings by Craig Deelsnyder et alia.

    But, and here is the catch... The OnSumbit event only gets called if
    the user clicks a Submit button. And unfortunately we have an
    application with dozens of pages, but nary a single Submit button. We
    use linkbuttons hooked up to events pretty much everywhere to do our
    saving (which seems to be standard practice) and linkbuttons do not
    trigger OnSubmit.

    Any suggestions on how to popup a "We are working on your request,
    please stop clicking" dialog?

    Diane "America's Developer" Selby
    Diane Selby, Jun 24, 2004
    #1
    1. Advertising

  2. Diane Selby

    Martin Guest

    onclick ?
    "Diane Selby" <> wrote in message
    news:...
    > Hi-
    >
    > I am developing an ASP.NET application that can take a few seconds to
    > process the request from the user. We are looking for a client-side
    > solution that will prevent users from resubmitting the page multiple
    > time in their irrational impatience.
    >
    > There are a few posts on this group which suggest that we use
    > JavaScript hooked up to the page's OnSubmit event to catch mulitple
    > submissions. See postings by Craig Deelsnyder et alia.
    >
    > But, and here is the catch... The OnSumbit event only gets called if
    > the user clicks a Submit button. And unfortunately we have an
    > application with dozens of pages, but nary a single Submit button. We
    > use linkbuttons hooked up to events pretty much everywhere to do our
    > saving (which seems to be standard practice) and linkbuttons do not
    > trigger OnSubmit.
    >
    > Any suggestions on how to popup a "We are working on your request,
    > please stop clicking" dialog?
    >
    > Diane "America's Developer" Selby
    Martin, Jun 24, 2004
    #2
    1. Advertising

  3. What you need to do is redirect to another page when the user clicks the
    button. This way the client immediately sees a "please wait" page.

    Place this when the button is clicked:

    Response.Redirect("Loading.Aspx?Page="TheFinishedPage.aspx")




    What this does is this:

    The Loading.aspx page gets called and will be loaded on the client, and the
    client will sit there until the code in TheFinishedPage.aspx has completed
    executing. When TheFinishedPage.aspx completes, the client is sent to that
    page, where you can display some kind of confirmation message, etc.

    You must, however, use session variables or something else like a db to
    store the information from the page you are transferring from so that
    TheFinishedPage.aspx will know what to do.

    It's a convenient way to have a message like "Loading. Please Wait..." so
    that the user cannot click any more controls that will post back to the
    server.

    Steve


    "Diane Selby" <> wrote in message
    news:...
    > Hi-
    >
    > I am developing an ASP.NET application that can take a few seconds to
    > process the request from the user. We are looking for a client-side
    > solution that will prevent users from resubmitting the page multiple
    > time in their irrational impatience.
    >
    > There are a few posts on this group which suggest that we use
    > JavaScript hooked up to the page's OnSubmit event to catch mulitple
    > submissions. See postings by Craig Deelsnyder et alia.
    >
    > But, and here is the catch... The OnSumbit event only gets called if
    > the user clicks a Submit button. And unfortunately we have an
    > application with dozens of pages, but nary a single Submit button. We
    > use linkbuttons hooked up to events pretty much everywhere to do our
    > saving (which seems to be standard practice) and linkbuttons do not
    > trigger OnSubmit.
    >
    > Any suggestions on how to popup a "We are working on your request,
    > please stop clicking" dialog?
    >
    > Diane "America's Developer" Selby
    Steve Caliendo, Jun 24, 2004
    #3
  4. Diane Selby

    Diane Selby Guest

    Steve-

    Redirecting to another page is a solution, but maybe not the solution
    we are looking for. In most cases, we want to display the same page
    after the button click. So, heading off to a "please wait" page and
    then back to the original page would be a bit bewildering for the
    user. I could see lots of complaints about that...

    What I'm dreaming of is a JavaScript client side method that will pop
    up an alert if the user clicks the button more than once before the
    results return. We may have to wire up a script to each button, but
    I'd rather have something that would work on a page level somehow...

    Anyhow, if anyone has something they can suggest, that would be fresh,
    yo!

    DD


    "Steve Caliendo" <> wrote in message news:<eVfru$>...
    > What you need to do is redirect to another page when the user clicks the
    > button. This way the client immediately sees a "please wait" page.
    >
    > Place this when the button is clicked:
    >
    > Response.Redirect("Loading.Aspx?Page="TheFinishedPage.aspx")
    >
    >
    >
    >
    > What this does is this:
    >
    > The Loading.aspx page gets called and will be loaded on the client, and the
    > client will sit there until the code in TheFinishedPage.aspx has completed
    > executing. When TheFinishedPage.aspx completes, the client is sent to that
    > page, where you can display some kind of confirmation message, etc.
    >
    > You must, however, use session variables or something else like a db to
    > store the information from the page you are transferring from so that
    > TheFinishedPage.aspx will know what to do.
    >
    > It's a convenient way to have a message like "Loading. Please Wait..." so
    > that the user cannot click any more controls that will post back to the
    > server.
    >
    > Steve
    >
    >
    > "Diane Selby" <> wrote in message
    > news:...
    > > Hi-
    > >
    > > I am developing an ASP.NET application that can take a few seconds to
    > > process the request from the user. We are looking for a client-side
    > > solution that will prevent users from resubmitting the page multiple
    > > time in their irrational impatience.
    > >
    > > There are a few posts on this group which suggest that we use
    > > JavaScript hooked up to the page's OnSubmit event to catch mulitple
    > > submissions. See postings by Craig Deelsnyder et alia.
    > >
    > > But, and here is the catch... The OnSumbit event only gets called if
    > > the user clicks a Submit button. And unfortunately we have an
    > > application with dozens of pages, but nary a single Submit button. We
    > > use linkbuttons hooked up to events pretty much everywhere to do our
    > > saving (which seems to be standard practice) and linkbuttons do not
    > > trigger OnSubmit.
    > >
    > > Any suggestions on how to popup a "We are working on your request,
    > > please stop clicking" dialog?
    > >
    > > Diane "America's Developer" Selby
    Diane Selby, Jun 25, 2004
    #4
  5. Diane Selby

    Guest

    On 25 Jun 2004 14:39:20 -0700, (Diane Selby)
    wrote:

    >Steve-
    >
    >Redirecting to another page is a solution, but maybe not the solution
    >we are looking for. In most cases, we want to display the same page
    >after the button click. So, heading off to a "please wait" page and
    >then back to the original page would be a bit bewildering for the
    >user. I could see lots of complaints about that...
    >
    >What I'm dreaming of is a JavaScript client side method that will pop
    >up an alert if the user clicks the button more than once before the
    >results return. We may have to wire up a script to each button, but
    >I'd rather have something that would work on a page level somehow...
    >
    >Anyhow, if anyone has something they can suggest, that would be fresh,
    >yo!
    >
    >DD
    >


    add something like this

    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
    sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
    sb.Append("this.value = 'Wait...';");
    sb.Append("this.disabled = true;");
    sb.Append(this.Page.GetPostBackEventReference(this.<buttonname>));
    sb.Append(";");
    this.<buttonname>.Attributes.Add("onclick", sb.ToString());

    remeber to change <buttonname> to the actual name of u're button.

    -Adam
    , Jun 25, 2004
    #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. Replies:
    0
    Views:
    425
  2. AD
    Replies:
    4
    Views:
    585
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Apr 18, 2007
  3. Matty Sarro

    Automated form submissions

    Matty Sarro, Oct 21, 2011, in forum: Python
    Replies:
    1
    Views:
    140
    Grant Edwards
    Oct 21, 2011
  4. Michael

    Handling large form submissions

    Michael, Dec 10, 2003, in forum: ASP General
    Replies:
    3
    Views:
    121
    John Beschler
    Dec 10, 2003
  5. Replies:
    0
    Views:
    153
Loading...

Share This Page