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

Home Posts Topics Members FAQ

Code is reexecuted when the user clicks Refresh

I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user clicks
the browser's Refresh button once the confirmation message is displayed, the
email is sent a second time (or a third, fourth, fifth, etc.). What can I do
to prevent the Refresh button from resending the email? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Jan 19 '07 #1
5 1112
RSH
Nathan,

You could set a session varaible that once the email was sent the session
variable would be sent and you would add a wrapper to check for a value in
the session variable before sending emails.

If they hit the refresh button does that cause a postback...I'm not sure.
If not, then you can simply check if the request is a postback...if it is
send the email...else dont.

HTH
Ron
"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user
clicks the browser's Refresh button once the confirmation message is
displayed, the email is sent a second time (or a third, fourth, fifth,
etc.). What can I do to prevent the Refresh button from resending the
email? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Jan 19 '07 #2
Maybe Response.Redire ct? That will flush out your POST headers to prevent
the submit from happening repeatedly

Jan 19 '07 #3
Keith Patrick wrote:
Maybe Response.Redire ct? That will flush out your POST headers to
prevent the submit from happening repeatedly
This is the approach we use. It works perfectly.

--

(O)enone
Jan 19 '07 #4
Nathan,

You can try to set a session variable that tells that the post has been
send.

Cor

"Nathan Sokalski" <nj********@hot mail.comschreef in bericht
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>I have a page which allows the user to send emails. After they click the
submit button, I display a confirmation message. However, if the user
clicks the browser's Refresh button once the confirmation message is
displayed, the email is sent a second time (or a third, fourth, fifth,
etc.). What can I do to prevent the Refresh button from resending the
email? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Jan 20 '07 #5
"Nathan Sokalski" <nj********@hot mail.comwrote in
news:#K******** ******@TK2MSFTN GP05.phx.gbl:
>
I have a page which allows the user to send emails. After they click
the submit button, I display a confirmation message. However, if the
user clicks the browser's Refresh button once the confirmation message
is displayed, the email is sent a second time (or a third, fourth,
fifth, etc.). What can I do to prevent the Refresh button from
resending the email? Thanks.
Session variables, database flag, cookies - since the web is stateless,
you'll need some sort of mechanism to track when the last request occured
and if the current request is valid.
Jan 20 '07 #6

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

Similar topics

7
2467
by: Jo | last post by:
Hi, I have a small (hopefully!) problem. I have two buttons on my web page and when button A is clicked, the code behind takes about 3 seconds to execute. While it's executing though, I don't want the user to be able to click button B. What I have found happens is that if user clicks button B while button A is still executing, the code behind button B will start executing straight after the code under A has finished, and there is no page...
1
1979
by: Shawn Benson | last post by:
I have a Windows form where a user enters an order number which returns a dataset that is bound to a datagrid. The problem is when a user clicks on a cell in the datagrid, then enters another order to get information for, everything is updated with the new data except the cell in the grid that was selected. This behavior does not occur when a table style is not applied to the datagrid. How do I refresh the datagrid so that the cell in...
1
1516
by: JBD | last post by:
Hi, I have a button that fires the below sub routine. This works fine if the user clicks the button as they are supposed to, even if they click it repeatedly. However, if you click "refresh" on the browswer, then it duplicates records. I believe this is happening because somehow it isnt doing the first part of my code which is to to an archive update. I can't for the life of me figure out why this happens only when you click refresh on...
10
1188
by: Tom Bower | last post by:
(VB newbie, no flames please) I have a simple one-form VB application which I want, on invocation, to start up, initialize and display the form (the UI), and then go execute some more code (a loop that checks for certain things etc.). Where would I put this "more code" -- now, I can make it do whatever I want in response to a standard UI event (like user clicks button) but I want the form to load and
4
9534
by: morc | last post by:
hi, is there any way to refresh the page when the user clicks back button?I have a jsp page that i need to regerenate everything everytime the user visits it. its either that or i want to disable the back button so to force the user to click a link so that hte page is refreshed. If anyone knows how to refresh on back button click or disable the back button please help me out.
1
6727
by: Badass Scotsman | last post by:
Hello, I have an application which should never allow the back button to be pushed without refreshing the previous page. For example: Step 1: User fills in form.html and presses submit Step 2: User see's results.html and clicks back to amend form
5
1072
by: Nathan Sokalski | last post by:
I have a page which allows the user to send emails. After they click the submit button, I display a confirmation message. However, if the user clicks the browser's Refresh button once the confirmation message is displayed, the email is sent a second time (or a third, fourth, fifth, etc.). What can I do to prevent the Refresh button from resending the email? Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
3
4015
by: Mike | last post by:
Is there a way to determine if a page was refreshed? I have a function that is called when the page loads, but when the user refreshes the page it calls the function again. Is there a way to call the function only when the page initially loads? I don't want it to load when the user clicks the refresh button.
4
2808
by: Peter | last post by:
ASP.NET 3.5 I have a web page and this web page has a DataList, when user hovers the mouse over a picture in the datalist a popup appers, this popup is a User Control and it has a cancel button. After the user clicks on the cancel button I want the DataList to refresh its self. How can I do that - how can I tell the DataList or the parent web page to refresh it's self from the Popup / User Control?
0
9525
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,...
1
10169
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
9050
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...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
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
5440
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
5569
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.