473,396 Members | 2,055 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,396 software developers and data experts.

ASP.NET Refresh Problem

hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a
record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page.
so the problem is that when i refresh the page, the last action that i have
done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...
Nov 17 '05 #1
4 4129
You can't exactly solve it. What you can do is to handle it on the server.
For example, you could set a Session variable when the insert occurs, and
check it before doing the insert. If the Session variable is there, you know
the record has been inserted already. Of course, you have to remove the
Session variable at some point in order to do another insert. But of course,
there are ways of doing that as well. There are other solutions as well. How
you handle it is up to you, based upon the functionality of your page, and
your creativity.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"wright" <yl**@wintech-soft.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page. so the problem is that when i refresh the page, the last action that i have done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...

Nov 17 '05 #2
You can't exactly solve it. What you can do is to handle it on the server.
For example, you could set a Session variable when the insert occurs, and
check it before doing the insert. If the Session variable is there, you know
the record has been inserted already. Of course, you have to remove the
Session variable at some point in order to do another insert. But of course,
there are ways of doing that as well. There are other solutions as well. How
you handle it is up to you, based upon the functionality of your page, and
your creativity.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"wright" <yl**@wintech-soft.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page. so the problem is that when i refresh the page, the last action that i have done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...

Nov 17 '05 #3
The problem is that when you press F5 IE sends excatly same info to the
server.
And server can not distinguish between first request and second.

The easiest thing is to redirect to the page (it could be the same page).

George.

"wright" <yl**@wintech-soft.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page. so the problem is that when i refresh the page, the last action that i have done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...

Nov 17 '05 #4
The problem is that when you press F5 IE sends excatly same info to the
server.
And server can not distinguish between first request and second.

The easiest thing is to redirect to the page (it could be the same page).

George.

"wright" <yl**@wintech-soft.com> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page. so the problem is that when i refresh the page, the last action that i have done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...

Nov 17 '05 #5

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

Similar topics

9
by: Mark | last post by:
I have a working PHP/MySQL application used for data entry. The data entry screen includes a "Save" button. The PHP code for this button looks like this: if (isset($_POST)) { if ($_POST ==...
4
by: Noel Wood | last post by:
Hello, I have a problem that I'm sure is simple but I have searched the newsgroup and have not found it posted before so I apologize if it has been asked heaps of times before. I have a page that...
3
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a...
5
by: Steve | last post by:
Hi, I have a private website for 20 people that is similar to a web email client like hotmail. There are two frames, one on the left with links for "New", "History", "Todays" and a frame on the...
12
by: Tarken | last post by:
Hi, I am trying to do some refactoring of a web site to ensure that it displays in the most web clients possible. One of the pages requires to be redirected to another automatically, for one...
4
by: Andrew Alger | last post by:
ok i have two forms. Customer.aspx and Parent_Searh.aspx. There is a button on Customer.aspx that when executed runs javascript code to open up parent_search as a popup. After the user searches...
10
by: tasmisr | last post by:
This is an old problem,, but I never had it so bad like this before,, the events are refiring when clicking the Browser refresh button. In the Submit button in my webform, I capture the server side...
1
by: ppatel | last post by:
Problem I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine). When click...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
12
by: martin1 | last post by:
All, is there window form refresh property? I try to set up window form refresh per minute. Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
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...

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.