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

Avoiding a refresh in ASP.NET 2, how-to?

Hi all,

I come from a ColdFusion background, and the majority of the time, here's
how we processed a page:
1) The Data entry page would have a submit button which would post to an
action page
2) The action page would do the validation and database processing, if
successful, the action page would <cflocation(similar to a
Response.Redirect or Server.Transfer) to a display page.

If the end-user hit F5 or Refresh on the toolbar of the browser, the final
display page would be refreshed, not the original page or the action page.
This prevented the database processing from occuring twice.

Note: the original data entry page DOES NOT post back to itself, like in
ASP.NET.

So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.

I'm noticing that on pages which I have an insert, delete, or updating going
on, the user submits the changes, and then when the page comes back...If the
user clicks Refresh/F5, then the page (will show the postback warning which
most users don't read and/or understand) will attempt to do the database
action again, thus causing potential problems.

Suggestions?

Thanks,
Brian
May 25 '07 #1
6 14846
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:uW**************@TK2MSFTNGP06.phx.gbl...
So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.
Google is your friend:
http://www.google.co.uk/search?sourc...revent+Refresh
--
http://www.markrae.net

May 25 '07 #2
You might also try:

if (!Page.IsPostback)
{
.......code that you only want to process once......
}

May 25 '07 #3
Thanks Mark, I tried google, but didn't use that keyword: prevent
Muchas gracias!

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:eE*************@TK2MSFTNGP06.phx.gbl...
"Brian Simmons" <ce******@newsgroup.nospamwrote in message
news:uW**************@TK2MSFTNGP06.phx.gbl...
>So, now that I'm on the ASP.NET 2 bandwagon, I'm curious as to how to
prevent the double database processing happening if/when a user clicks
F5/Refresh.

Google is your friend:
http://www.google.co.uk/search?sourc...revent+Refresh
--
http://www.markrae.net

May 25 '07 #4
That won't help in the situation described by the OP, since if the last
action was an HTTP POST and you hit Refresh on your browser, it's going to do
the POST again.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"vcuankitdotnet" wrote:
You might also try:

if (!Page.IsPostback)
{
.......code that you only want to process once......
}

May 25 '07 #5
Hi Brian,

For ASP.NET web page model, if you still want to prevent duplicated submit
of page postback processing, you can still use the same way like what you
do in code fusion. You can let the ASP.NET page postback(when click button
or other postback control) as normal, and do the server-side processing in
page/control's postback event, however, after the processing code , you add
an additional statement to redirect the page. e.g.

Response.Redirect("the page itself....")

Thus, after the page is successuflly finishing the postback, it won't
suffer from duplicated submit issue. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
May 28 '07 #6
Hi Steven,

Thank you for the reply. I implemented the solution exactly as you
specified. Works like a charm.

Thanks,
Brian

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:%2******************@TK2MSFTNGHUB02.phx.gbl.. .
Hi Brian,

For ASP.NET web page model, if you still want to prevent duplicated submit
of page postback processing, you can still use the same way like what you
do in code fusion. You can let the ASP.NET page postback(when click button
or other postback control) as normal, and do the server-side processing in
page/control's postback event, however, after the processing code , you
add
an additional statement to redirect the page. e.g.

Response.Redirect("the page itself....")

Thus, after the page is successuflly finishing the postback, it won't
suffer from duplicated submit issue. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


May 29 '07 #7

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

Similar topics

11
by: Tom Post | last post by:
I am doing a simple php header refresh -- header('refresh: 10; url=msgs.php'); that just does a call back to my script every 10 seconds. Things work great when the page is first loaded up, but if...
10
by: Nick Craig-Wood | last post by:
I'm trying to avoid using shell metacharacters in os.popen in a portable fashion. os.popen() only seems to take a string as the command which would need tricky quoting. os.popen2() can take a...
7
by: Leonardo D'Ippolito | last post by:
Hello all, I need to get the MAC ADDRESS of a NIC without using WMI. Microsoft has this piece of code in their knowledge base: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q118623 ...
1
by: Stan | last post by:
If a page has a button with event handler private void btnAdd_Click(object sender, System.EventArgs e) { ....... } this event handler fires every time I refresh the page in the browser with...
6
by: vvenk | last post by:
Hello: I am using frames. How can I refresh the browser programmatically so that all the frames are reloaded? Not using javascript, though!
2
by: Dan | last post by:
Hi, I have a Datagrid in a simple form that I programmatically modify using something like that : Me.DataGrid1(RowID, ColID) = "blablabla" But my cell wont refresh unless I click on another...
2
by: sarantvmalai | last post by:
hi all, Actually i need the refresh code in PHP. i searched net but it all are time limit that is refresh <META HTTP-EQUIV="Refresh", content="3;URL=http://www.localhost/exp_det.php" >'.. but...
7
Akatz712
by: Akatz712 | last post by:
I have a javascript routine which is at the bottom of the HTML right before the </body>. In it, I initialize some form fields. This code I know only gets executed when the page first loads and when I...
2
by: Ted Dawson | last post by:
This code refreshes correctly: <% Response.AddHeader "Refresh", "5;URL=page.asp" %> This code does not refresh: <% Response.AddHeader "Refresh", "1140;URL=page.asp" %> Is there a limit on...
1
by: Amzul | last post by:
hello all i use <meta http-equiv="refresh" content="300" /> in the head but i notice that the pictures in the page are not refreshing i have picturs *.png its graphs so i can tell nothing is...
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: 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
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,...
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
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...
0
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,...
0
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...

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.