473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.redire ct 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 3177
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.redire ct 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.redire ct 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(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click
Response.Write( "Write this line once!")
Button1.Attribu tes.Add("onClic k", _
"document.f orms[0]." & Button1.UniqueI D & ".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.redire ct 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
2343
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 various techniques in the past (depending on circumstances) but I'd be interested in the techniques you guys currently use. Thanks --
3
1768
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 mozilla and MSIE - is this a good way to solve the problem? Is there a better alternative? Have I done anything stupid? My aim was to disable the normal submit process then use javascript to submit which appears to bypass that and work...
5
3768
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 processing on certain key/mouse events 3) If key/mouse events interrupt processing, the events should not be discarded since they need to be handled but AFTER the current processing is complete
6
2857
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 data from the button is not available at this time as to allow the table to properly update. So basically, I need to call UpdateTable() twice, once from page load and once from button. This causes problems with my application, and I was trying...
0
5754
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 selected, it causes the ServerClick event to be called twice. Here's the code: You'll see that there are two grids on the page, and that the function SetupDataGrid populates data to the two grid. There are also
3
8823
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 twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what to look for to get this sorted please. <p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
9
4745
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 day. It worked wonderfully, but it was in C# So I converted it to VB with http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx It got upset about private and so I changed those to protected
4
1881
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 run the same code twice. Aleks Kleyn
9
2894
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 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
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.