473,545 Members | 2,041 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 1103
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
2446
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...
1
1968
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...
1
1503
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...
10
1175
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...
4
9520
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...
1
6706
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
1066
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...
3
4005
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
2794
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...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7664
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. ...
0
7918
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7436
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...
0
7766
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5981
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...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
715
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...

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.