473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Preventing button code being run twice

I have a v2.0 site that has a form with a GO button which runs another
application and then returns some data which is then processed and then I
issue a response.redirect to another form to display the returned data.

My problem is that it is possible for a user to click the button several
times causing the external app to run several times.

My first thought was to set the button.enabled = false as soon as it is
clicked but that does not work, presumably because of caching.

What is the best way to stop this code executing more than once or until
the page is opened again?

Thanks

Bill
Aug 16 '06 #1
3 3163
Can you set the caption of the button to something like "Processing..."
when it's clicked?

Then when the user clicks the button if it equals "Processing..." do
nothing.
Bill wrote:
I have a v2.0 site that has a form with a GO button which runs another
application and then returns some data which is then processed and then I
issue a response.redirect to another form to display the returned data.

My problem is that it is possible for a user to click the button several
times causing the external app to run several times.

My first thought was to set the button.enabled = false as soon as it is
clicked but that does not work, presumably because of caching.

What is the best way to stop this code executing more than once or until
the page is opened again?

Thanks

Bill
Aug 16 '06 #2
Otherwise, you could just disable the button after it has been clicked.
Use a variable that would change if the button had been clicked. Then
if you needed the user to be able to click that same button again
later, have another variable that would re-enable.

Bill wrote:
I have a v2.0 site that has a form with a GO button which runs another
application and then returns some data which is then processed and then I
issue a response.redirect to another form to display the returned data.

My problem is that it is possible for a user to click the button several
times causing the external app to run several times.

My first thought was to set the button.enabled = false as soon as it is
clicked but that does not work, presumably because of caching.

What is the best way to stop this code executing more than once or until
the page is opened again?

Thanks

Bill
Aug 16 '06 #3
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Response.Write("Write this line once!")
Button1.Attributes.Add("onClick", _
"document.forms[0]." & Button1.UniqueID & ".disabled =
true;")
End Sub
Bill wrote:
I have a v2.0 site that has a form with a GO button which runs another
application and then returns some data which is then processed and then I
issue a response.redirect to another form to display the returned data.

My problem is that it is possible for a user to click the button several
times causing the external app to run several times.

My first thought was to set the button.enabled = false as soon as it is
clicked but that does not work, presumably because of caching.

What is the best way to stop this code executing more than once or until
the page is opened again?

Thanks

Bill
Aug 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: CJM | last post by:
How do people go about preventing the user from submitting a form for a 2nd time? For example, the user submits a form, clicks on the back button, and the submits the form again. I have used...
3
by: shortbackandsides.no | last post by:
I've been having trouble preventing users pressing Enter part way down a form so the incomplete form gets submitted. I came up with a possible solution - the code below seems to work in both...
5
by: Bill Henning | last post by:
Does anyone know a good method of preventing keyboard and mouse events from interrupting processing? My situation is: 1) I need to track and handle all key and mouse events 2) I need to perform...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
9
by: mosscliffe | last post by:
I am sorry but I am all very new and slow at understanding all this ASP.NET2. I found some code which showed how to page with a repeater. All very excited as I had been looking for this all...
4
by: Aleks Kleyn | last post by:
In asp.net I can put code for button click event. However I come to this event twice. What is the reason and how to prevent or check second entry to this event. I need to make sure that i do not...
9
by: Ned White | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.