preventing users from submitting inputs twice

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 [ Mi, 09 April 2008 13:06 ] [ ID #1938608 ]

Re: preventing users from submitting inputs twice

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 [at] > schreef in bericht
news:O$22MHjmIHA.484 [at] TK2MSFTNGP06.phx.gbl...
> 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 [ Mi, 09 April 2008 13:19 ] [ ID #1938610 ]

Re: preventing users from submitting inputs twice

on the click event disable the button

sender.Enabled = False


"Ned White" <nedwhite [at] > wrote in message
news:O$22MHjmIHA.484 [at] TK2MSFTNGP06.phx.gbl...
> 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
>
>
>
Premium Plastics [ Mi, 09 April 2008 13:46 ] [ ID #1938613 ]

Re: preventing users from submitting inputs twice

On Wed, 9 Apr 2008 14:06:30 +0300, "Ned White" <nedwhite [at] > 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
rossum [ Mi, 09 April 2008 15:06 ] [ ID #1938620 ]

Re: preventing users from submitting inputs twice

On Apr 9, 7:46=A0am, "ThatsIT.net.au" <me [at] work> wrote:
> on the click event disable the button
>
> sender.Enabled =3D False
>

That does not work, that event is executed in the server, he needs
something that execute in the client.
ignacio.machin [ Mi, 09 April 2008 15:49 ] [ ID #1938626 ]

Re: preventing users from submitting inputs twice

On Apr 9, 7:06=A0am, "Ned White" <nedwhite [at] > 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 =A0or they can refresh the all page by pressi=
ng
> 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 pa=
ge
> ?
>
> 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=3D'FakeButtonToMoveAround' Width=3D'150px'
type=3D'button' value=3D'Processing ...' disabled=3D'disabled'
style=3D'visibility:hidden; position:absolute;z-index:1;' />
<script language=3D'javascript' type=3D'text/
javascript'>

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

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

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

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

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

}
ignacio.machin [ Mi, 09 April 2008 15:54 ] [ ID #1938628 ]

Re: preventing users from submitting inputs twice

On Apr 9, 9:06=A0am, rossum <rossu... [at] coldmail.com> wrote:
> On Wed, 9 Apr 2008 14:06:30 +0300, "Ned White" <nedwhite [at] > 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 the=
y
> >can click it again and again =A0or they can refresh the all page by press=
ing
> >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 p=
age
> >?
>
> >Thanks..
>
> >NED
>
> Firstly put up an immediate response along the lines of "We have
> received your submission. =A0It will take a few seconds to process.
> Please do not resend yout details or refresh this page." =A0That 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. =A0Always 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 [ Mi, 09 April 2008 15:55 ] [ ID #1938629 ]

Re: preventing users from submitting inputs twice

Look at paypal. They have a button which when clicked has JavaScript to
disable the button and then post the form.
Peter Morris [ Mi, 09 April 2008 18:17 ] [ ID #1938649 ]

Re: preventing users from submitting inputs twice

Ignacio Machin ( .NET/ C# MVP ) wrote:
> On Apr 9, 7:06 am, "Ned White" <nedwhite [at] > 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:lasse [at] vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
lasse [ Mi, 09 April 2008 18:21 ] [ ID #1938650 ]

Re: preventing users from submitting inputs twice

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin [at] gmail.com> wrote in
message
news:2455e088-6484-4fdc-b778-27c84b398ef5 [at] t54g2000hsg.google groups.com...
On Apr 9, 7:46 am, "ThatsIT.net.au" <me [at] 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
Premium Plastics [ Do, 10 April 2008 02:13 ] [ ID #1939325 ]

Re: preventing users from submitting inputs twice

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 [at] > schreef in bericht
news:O$22MHjmIHA.484 [at] TK2MSFTNGP06.phx.gbl...
> 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
>
>
>
notmyfirstname [ Do, 10 April 2008 06:11 ] [ ID #1939343 ]

Re: preventing users from submitting inputs twice

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 [ Fr, 11 April 2008 03:41 ] [ ID #1940136 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » preventing users from submitting inputs twice

Vorheriges Thema: AJAX PopupExtender Not Working with Label
Nächstes Thema: ASP.Net Tutorials