Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 How do i prevent refresh ?

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 05:38:50
Hello All,
is there a simple way of preventing page refresh in .net

I had to write some code to assign a session variable to prevent refereshing the page.

Any simpler methods ?

thanks
Ehi

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-03 : 05:46:35
How do you stop keybord shortcut Ctrl-F5?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 05:50:03
???
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-03 : 05:54:44
What I meant, is that you cannot stop the refresh of a page.
An user can press F5 or Ctrl-F5 to refresg the page anyway.
Or click the Refresh button.

Or maybe you are referring to another underlying problem and think refresh of page is the problem?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 06:23:20
no no no

Well with webforms, when u have a page that might take a while to process. You dont want users refreshing the page in an auto postback. I wrote a script to stop it. But having loads of ajax controls, which also make postbacks to the page when called. It conflicts with the script and loops endlessly.

So its flawed. so am looking for a simpler way around it.

Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 08:11:39
quote:
Originally posted by Peso

How do you stop keybord shortcut Ctrl-F5?



E 12°55'05.63"
N 56°04'39.26"




I got a way around it.

I wrote a custom function on the button event. But any other options are welcome.

Also saw
http://www.dotnetjunkies.com/WebLog/leon/archive/2006/02/23/135525.aspx

By the way Peter its just F5
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-03 : 09:07:05
For an ordinary refresh, yes.
If you also want to reload the cache, use Ctrl-F5.

See
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsNT/UserTips/IEandExplorer/XPsIEKeyboardShortcuts.html
http://www.columbia.edu/~jl2402/IETips.html#27
http://en.wikipedia.org/wiki/Wikipedia:Troubleshooting



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 09:26:54
ok
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-03 : 10:29:19
I found a very simple way.

Set a hidden value in the form, and increment it on the button1 click event. So if it is a postback the value is 1 and if its onpage load the value is 0

And for the button load event, it will redirect it to a fresh page if its a referesh.

Quite simple :)



string SendOnce = count.Value.ToString();
if (SendOnce == "1")
{
goto endexecution;
}
if (SendOnce == "0")
{
count.Value = "1";
}

Go to Top of Page
   

- Advertisement -