By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

ASP.NET Refresh Problem

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.