Double clicking a web page button

F

Flyguy

I have a button on a web page that calls a function. That function takes a
few seconds to complete. during that time the user can press the button
again. If they do this it will crash the system. Is there any way of
disabling the page from further submits? Is there a better way of handling
this?
 
C

Cowboy \(Gregory A. Beamer\)

Thanks Mark.

I am sure someone has something up to date. He can also ignore a submit with
the same information, or from the same user, although that requires a bit
more work.

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
S

Steven Cheng

Hi Flyguy,

The problem you mentioned (double page postback/submit) could be caused by
many different kind of client operations

1. User click submit button more than once(when network bandwidth is no
good)

2. User refresh the current page(by click F5 or manually refresh page )
after he already submit the page
...

There are also many different kind of solutions. Some of them rely on
client-side script(to disable button or t he entire page) or using
server-side timestamp flag to detect invalid postback(duplicted ones). Here
are two web article which explained both ones, you can have look for
reference:

#Preventing Duplicate Record Insertion on Page Refresh
http://aspalliance.com/687_Preventing_Duplicate_Record_Insertion_on_Page_Ref
resh.all

#Prevent Users from Submitting a Form Twice
http://www.4guysfromrolla.com/webtech/100406-1.shtml

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
From: =?Utf-8?B?Rmx5Z3V5?= <[email protected]>
Subject: Double clicking a web page button
Date: Fri, 16 Jan 2009 07:09:01 -0800
I have a button on a web page that calls a function. That function takes
a
 
S

Steven Cheng

Hi Flyguy,

Have you got any progress on this issue or does the suggestion in previous
replied help you?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
From: =?Utf-8?B?Rmx5Z3V5?= <[email protected]>
Subject: Double clicking a web page button
Date: Fri, 16 Jan 2009 07:09:01 -0800
I have a button on a web page that calls a function. That function takes
a
 
J

James BT

Hi Steven

This is quite a typical issue, particularly if performance is not to great
over the network, ie, if things are going slow it doesn't always appear to
the user that something is happening, and they click again. I have addressed
similar problems as follows:

Buttons are slightly easier to deal with than hyperlinks, in that they can
be disabled when the onClick event is fired, either within the .net onClick
event (button.disabled = true), or by using a Javascript function (provided
your button is accessible within the DOM), which then subsequently calls the
required action of the button.

I quite often build subroutines to render my buttons, with the buttons
actually placed inside <divs> or <spans>. This way, you can use a JavaScript
call to hide or replace the contents of the <divs> or <spans> to remove the
button. This technique is especially useful for preventing double clicks on
Hyperlinks - which of course cannot be disabled in the same way as buttons.

For example you could have a situation like this:

<div id="button_div">Button goes here</div>
When the button is clicked, a javascript could be called that does the
following:

<script language="javaScript">
function myButtonOnClick() {

var objButtonDiv = document.getElementById('button_div');
objButtonDiv.innerHTML = "..You've clicked this";

//Do something else now, ie the action of your button

}
</script>

This code simply gets rid of the button as soon as its clicked and replaces
it with text (or a graphic of your button that is grayed out for example).
As it is no longer a button, it can't be clicked any more.

I don't have any code on me, but could give you a few pointers if I bring
the code back from work. Let me know if you need any further asistance. I
appreciate that I haven't given you a full solution as such but naybe I have
given you a few ideas about how you might tackle the problem.

Good luck

James Stoddern, Senior Developer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top