preventing users from submitting inputs twice

Discussion in 'ASP .Net' started by Ned White, Apr 9, 2008.

  1. Ned White

    Ned White Guest

    Hi All,

    Im my c# web project, users click a submit button for credit card payment
    process.
    On the web server side ( on ButtonClick_Event) the user's input(name,date,cc
    number etc.) is processed and some transactional database processes are
    taken based on the inputs.

    My problem is, users may think that the button click did not work, so they
    can click it again and again or they can refresh the all page by pressing
    the F5 button.
    And These actions can lead to two or more submissions, resulting in more
    database records being added for the same payment request.

    How can i prevent users from submitting inputs twice and refreshing the page
    ?

    Thanks..

    NED
     
    Ned White, Apr 9, 2008
    #1
    1. Advertising

  2. Hi Ned,

    Maybe you can navigate away from the page and put a mechanism in place that
    detects if a user allready inserted a payment record?

    With kind regards,

    Matthijs Krempel

    "Ned White" <nedwhite@> schreef in bericht
    news:O$...
    > Hi All,
    >
    > Im my c# web project, users click a submit button for credit card payment
    > process.
    > On the web server side ( on ButtonClick_Event) the user's
    > input(name,date,cc number etc.) is processed and some transactional
    > database processes are taken based on the inputs.
    >
    > My problem is, users may think that the button click did not work, so they
    > can click it again and again or they can refresh the all page by pressing
    > the F5 button.
    > And These actions can lead to two or more submissions, resulting in more
    > database records being added for the same payment request.
    >
    > How can i prevent users from submitting inputs twice and refreshing the
    > page ?
    >
    > Thanks..
    >
    > NED
    >
    >
    >
     
    Matthijs Krempel, Apr 9, 2008
    #2
    1. Advertising

  3. on the click event disable the button

    sender.Enabled = False


    "Ned White" <nedwhite@> wrote in message
    news:O$...
    > Hi All,
    >
    > Im my c# web project, users click a submit button for credit card payment
    > process.
    > On the web server side ( on ButtonClick_Event) the user's
    > input(name,date,cc number etc.) is processed and some transactional
    > database processes are taken based on the inputs.
    >
    > My problem is, users may think that the button click did not work, so they
    > can click it again and again or they can refresh the all page by pressing
    > the F5 button.
    > And These actions can lead to two or more submissions, resulting in more
    > database records being added for the same payment request.
    >
    > How can i prevent users from submitting inputs twice and refreshing the
    > page ?
    >
    > Thanks..
    >
    > NED
    >
    >
    >
     
    ThatsIT.net.au, Apr 9, 2008
    #3
  4. On Apr 9, 7:46 am, "ThatsIT.net.au" <me@work> wrote:
    > on the click event disable the button
    >
    > sender.Enabled = False
    >


    That does not work, that event is executed in the server, he needs
    something that execute in the client.
     
    Ignacio Machin ( .NET/ C# MVP ), Apr 9, 2008
    #4
  5. On Apr 9, 7:06 am, "Ned White" <nedwhite@> wrote:
    > Hi All,
    >
    > Im my c# web project, users click a submit button for credit card payment
    > process.
    > On the web server side ( on ButtonClick_Event) the user's input(name,date,cc
    > number etc.) is processed and some transactional database processes are
    > taken based on the inputs.
    >
    > My problem is, users may think that the button click did not work, so they
    > can click it again and again  or they can refresh the all page by pressing
    > the F5 button.
    > And These actions can lead to two or more submissions, resulting in more
    > database records being added for the same payment request.
    >
    > How can i prevent users from submitting inputs twice and refreshing the page
    > ?
    >
    > Thanks..
    >
    > NED


    This is not as easy as it sounds problem, the main issue is that you
    cannot disable the button cause it would disable the postback.
    The solution I use is to have another hidden button and put it over
    the submit button.
    Here is the javascript I use for it, You have a button that needs to
    position over your real button, for that you need to calculate the
    position (FindPost)

    let me know if you have any problem with the code


    <input id='FakeButtonToMoveAround' Width='150px'
    type='button' value='Processing ...' disabled='disabled'
    style='visibility:hidden; position:absolute;z-index:1;' />
    <script language='javascript' type='text/
    javascript'>

    function findPos(obj) {
    var curleft = curtop = 0;

    if (obj.offsetParent) {
    do {
    curleft += obj.offsetLeft;
    curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);

    }
    var retvar = new Object();
    retvar.curleft = curleft;
    retvar.curtop = curtop
    return retvar;
    }

    function PutTheOtherButton(realc,
    FakeButtonToMoveAround)
    {
    var fakec =
    document.getElementById(FakeButtonToMoveAround);

    var pos = findPos( realc);
    fakec.style.zIndex = realc.style.zIndex+10;
    fakec.style.posLeft = pos.curleft;
    fakec.style.posTop = pos.curtop;
    fakec.style.visibility = 'visible';
    fakec.style.pixelWidth = realc.style.pixelWidth;
    fakec.width = realc.width;
    fakec.style.pixelWidth = realc.style.pixelWidth;
    fakec.style.visibility = 'visible';

    }
     
    Ignacio Machin ( .NET/ C# MVP ), Apr 9, 2008
    #5
  6. On Apr 9, 9:06 am, rossum <> wrote:
    > On Wed, 9 Apr 2008 14:06:30 +0300, "Ned White" <nedwhite@> wrote:
    > >Hi All,

    >
    > >Im my c# web project, users click a submit button for credit card payment
    > >process.
    > >On the web server side ( on ButtonClick_Event) the user's input(name,date,cc
    > >number etc.) is processed and some transactional database processes are
    > >taken based on the inputs.

    >
    > >My problem is, users may think that the button click did not work, so they
    > >can click it again and again  or they can refresh the all page by pressing
    > >the F5 button.
    > >And These actions can lead to two or more submissions, resulting in more
    > >database records being added for the same payment request.

    >
    > >How can i prevent users from submitting inputs twice and refreshing the page
    > >?

    >
    > >Thanks..

    >
    > >NED

    >
    > Firstly put up an immediate response along the lines of "We have
    > received your submission.  It will take a few seconds to process.
    > Please do not resend yout details or refresh this page."  That tells
    > the customer that you have got the transaction and are working on it.
    > Once you have finished processing then put up a "Thank you for your
    > custom" response.  Always give immediate feedback to the customer so
    > they know what is happening.
    >
    > Secondly keep a record of all recent transactions and query if any
    > duplicates come up within say ten minutes.
    >
    > rossum- Hide quoted text -
    >
    > - Show quoted text -


    IMHO it's just better to disable the submit mechanism.
    You could also use a sort of veil control
     
    Ignacio Machin ( .NET/ C# MVP ), Apr 9, 2008
    #6
  7. Ned White

    Peter Morris Guest

    Look at paypal. They have a button which when clicked has JavaScript to
    disable the button and then post the form.
     
    Peter Morris, Apr 9, 2008
    #7
  8. Ignacio Machin ( .NET/ C# MVP ) wrote:
    > On Apr 9, 7:06 am, "Ned White" <nedwhite@> wrote:
    >> Hi All,
    >>
    >> Im my c# web project, users click a submit button for credit card payment
    >> process.
    >> On the web server side ( on ButtonClick_Event) the user's input(name,date,cc
    >> number etc.) is processed and some transactional database processes are
    >> taken based on the inputs.
    >>
    >> My problem is, users may think that the button click did not work, so they
    >> can click it again and again or they can refresh the all page by pressing
    >> the F5 button.
    >> And These actions can lead to two or more submissions, resulting in more
    >> database records being added for the same payment request.
    >>
    >> How can i prevent users from submitting inputs twice and refreshing the page
    >> ?
    >>
    >> Thanks..
    >>
    >> NED

    >
    > This is not as easy as it sounds problem, the main issue is that you
    > cannot disable the button cause it would disable the postback.
    > The solution I use is to have another hidden button and put it over
    > the submit button.
    > Here is the javascript I use for it, You have a button that needs to
    > position over your real button, for that you need to calculate the
    > position (FindPost)


    Does that change the focus away from the button the user pressed? If
    not, a quick tap on the enter key will resubmit, regardless of how much
    you've stuffed on top of the button.

    There is one for-sure way to prevent double-orders:

    1. generate a unique id (guid) alongside the order process
    2. keep the guid with the order on all pages, up to the submit button
    3. prevent any order from being processed if the guid is already in the
    "processed" list

    Couple that with your visual change on the button, and you should be set.

    --
    Lasse Vågsæther Karlsen
    mailto:
    http://presentationmode.blogspot.com/
    PGP KeyID: 0xBCDEA2E3
     
    Lasse Vågsæther Karlsen, Apr 9, 2008
    #8
  9. "Ignacio Machin ( .NET/ C# MVP )" <> wrote in
    message
    news:...
    On Apr 9, 7:46 am, "ThatsIT.net.au" <me@work> wrote:
    > on the click event disable the button
    >
    > sender.Enabled = False
    >


    That does not work, that event is executed in the server, he needs
    something that execute in the client.
    this.disabled = true
     
    ThatsIT.net.au, Apr 10, 2008
    #9
  10. Ned,

    I never will make this at single step process. At least you need a step,
    wherin the user can verify what his/her input was (withouth sending of
    course confidential information) and then process "the already gotten
    information" with a kind of process button only one time.

    (And don't forget to tell that it is processed)

    Just my thought, the implementation is yours.

    Cor

    "Ned White" <nedwhite@> schreef in bericht
    news:O$...
    > Hi All,
    >
    > Im my c# web project, users click a submit button for credit card payment
    > process.
    > On the web server side ( on ButtonClick_Event) the user's
    > input(name,date,cc number etc.) is processed and some transactional
    > database processes are taken based on the inputs.
    >
    > My problem is, users may think that the button click did not work, so they
    > can click it again and again or they can refresh the all page by pressing
    > the F5 button.
    > And These actions can lead to two or more submissions, resulting in more
    > database records being added for the same payment request.
    >
    > How can i prevent users from submitting inputs twice and refreshing the
    > page ?
    >
    > Thanks..
    >
    > NED
    >
    >
    >
     
    Cor Ligthert[MVP], Apr 10, 2008
    #10
  11. Ned White

    Arne Vajhøj Guest

    Lasse Vågsæther Karlsen wrote:
    > There is one for-sure way to prevent double-orders:
    >
    > 1. generate a unique id (guid) alongside the order process
    > 2. keep the guid with the order on all pages, up to the submit button
    > 3. prevent any order from being processed if the guid is already in the
    > "processed" list
    >
    > Couple that with your visual change on the button, and you should be set.


    That is indeed the way to do it.

    It is known as Synchronizer Token Pattern or just Token Pattern.

    Arne
     
    Arne Vajhøj, Apr 11, 2008
    #11
  12. Ned White

    Jerry C Guest

    I use:



    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <script language="javascript" type="text/javascript" >
    function HideDiv()
    {
    var divM = document.getElementById("divMain");
    divM.style.visibility = 'hidden';
    }

    </script>
    <body>
    <form id="form1" runat="server" onsubmit="HideDiv();">
    <div id="divMain">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
    </body>
    </html>


    --
    Jerry


    "Cor Ligthert[MVP]" wrote:

    > Ned,
    >
    > I never will make this at single step process. At least you need a step,
    > wherin the user can verify what his/her input was (withouth sending of
    > course confidential information) and then process "the already gotten
    > information" with a kind of process button only one time.
    >
    > (And don't forget to tell that it is processed)
    >
    > Just my thought, the implementation is yours.
    >
    > Cor
    >
    > "Ned White" <nedwhite@> schreef in bericht
    > news:O$...
    > > Hi All,
    > >
    > > Im my c# web project, users click a submit button for credit card payment
    > > process.
    > > On the web server side ( on ButtonClick_Event) the user's
    > > input(name,date,cc number etc.) is processed and some transactional
    > > database processes are taken based on the inputs.
    > >
    > > My problem is, users may think that the button click did not work, so they
    > > can click it again and again or they can refresh the all page by pressing
    > > the F5 button.
    > > And These actions can lead to two or more submissions, resulting in more
    > > database records being added for the same payment request.
    > >
    > > How can i prevent users from submitting inputs twice and refreshing the
    > > page ?
    > >
    > > Thanks..
    > >
    > > NED
    > >
    > >
    > >

    >
     
    Jerry C, May 21, 2008
    #12
    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. Charlie
    Replies:
    1
    Views:
    332
    Kevin Spencer
    Oct 27, 2004
  2. brik

    Preventing users from adding items in ArrayEditor

    brik, Oct 25, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    139
  3. brik

    Preventing users from adding items in ArrayEditor

    brik, Oct 25, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    109
  4. Karthik

    Preventing same user from logging twice

    Karthik, Mar 18, 2005, in forum: ASP General
    Replies:
    1
    Views:
    190
    Patrice
    Mar 18, 2005
  5. donpro
    Replies:
    2
    Views:
    108
    Bart Van der Donck
    Nov 9, 2007
Loading...

Share This Page