473,387 Members | 1,540 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,387 software developers and data experts.

ASP.NET Detect Browser Refresh

I am relatively new to ASP.NET and just got my bound datagrid utilizing a
typed dataset to work the way I want to add, delete and update data.
The problem I am running into now is when clicking refresh on the browser
after adding a new record. Since the browser sends the same information back
to the server, the same data row is attempted to be inserted again.
Obviously this is not desirable.
I see no simple way to determine if the request is a refresh (so my code can
ignore the insert) or a new request.
This must be a common problem, yet I find very little information on it
anywhere.
Am I missing something? How is this typically handled?
--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

Jul 21 '05 #1
2 5216
This isn't really an ASP.NET question specifically as the same thing applied
in ASP.
One way, not the best is to set a session variable when the form is posted.
Only insert if the session variable hasn't already been set. Make sense?
-Francis Shanahan
http://www.FrancisShanahan.com

"Alphonse Giambrone" <NO**********@example.invalid> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
I am relatively new to ASP.NET and just got my bound datagrid utilizing a
typed dataset to work the way I want to add, delete and update data.
The problem I am running into now is when clicking refresh on the browser
after adding a new record. Since the browser sends the same information back to the server, the same data row is attempted to be inserted again.
Obviously this is not desirable.
I see no simple way to determine if the request is a refresh (so my code can ignore the insert) or a new request.
This must be a common problem, yet I find very little information on it
anywhere.
Am I missing something? How is this typically handled?
--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us

Jul 21 '05 #2
Thanks, that works. I guess I was just so surprised that in all the
walk-throughs and samples for the data grid, this was never mentioned.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Francis Shanahan" <fs@NoSpamTodayThanks.francisshanahan.com> wrote in
message news:uW****************@TK2MSFTNGP11.phx.gbl...
This isn't really an ASP.NET question specifically as the same thing applied in ASP.
One way, not the best is to set a session variable when the form is posted. Only insert if the session variable hasn't already been set. Make sense?
-Francis Shanahan
http://www.FrancisShanahan.com

"Alphonse Giambrone" <NO**********@example.invalid> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
I am relatively new to ASP.NET and just got my bound datagrid utilizing a typed dataset to work the way I want to add, delete and update data.
The problem I am running into now is when clicking refresh on the browser after adding a new record. Since the browser sends the same information

back
to the server, the same data row is attempted to be inserted again.
Obviously this is not desirable.
I see no simple way to determine if the request is a refresh (so my code

can
ignore the insert) or a new request.
This must be a common problem, yet I find very little information on it
anywhere.
Am I missing something? How is this typically handled?
--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


Jul 21 '05 #3

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

Similar topics

1
by: Matt | last post by:
When the page is refresh, it will first call window_unload() and then call window_load(). The problem is I window_unload() is invoked when the user click close button, or right top icon close...
4
by: sm mehta | last post by:
Hi, I have a web Application that must be licensed. When Customer buys 2 licensees for my application they can only have 2 copies open at a time. What I am doing right now is, I am storing No....
5
by: J-T | last post by:
Is there a way to detect if a user has refreshed a page in asp.net? Thanks a lot
2
by: Alphonse Giambrone | last post by:
I am relatively new to ASP.NET and just got my bound datagrid utilizing a typed dataset to work the way I want to add, delete and update data. The problem I am running into now is when clicking...
1
by: kaushalmbhavsar | last post by:
Hi I have couple of pages that maintain some stateful information and i need to detect browser back/refresh button press and loged out user. Is there a simple mechanims in .NET (specially in...
11
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect the close event in browser, which is the best performance for do this ? What's up with Alt+F4, Refresh, user clicks X,...
0
by: neo2020 | last post by:
Hi all, Is it possible for us to detect the browser refresh event ? I am thinking of comparing the current browser loaded URL with the target url. If they are the same, then imply it is an refresh...
4
by: nrocha | last post by:
Hello, I've been trying to detect when a user closes a page or navigates away from it. This is part of a solution for locking pages (that is, if a user enters a page, no one else can enter it...
5
by: =?Utf-8?B?QW5keQ==?= | last post by:
As per the question really. Not trying to stop them leaving, but just detect WHEN they leave the site
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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...
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,...

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.