471,123 Members | 845 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

how to prevent to go to the previous page?

Hi,

the user gets a form to fill. All the filled values are put into session
variables.
I want to prevent that he could click to the previous arrow of the browser
and then comes back to the form. Is that possible with asp.net?

Or, is it possible to clear the session when leaving the form page by
clicking the previous arrow?

Thanks
Eric
Nov 9 '08 #1
5 3567
On Nov 9, 11:26*am, "Eric" <e...@sdsclem.powrote:
Hi,

the user gets a form to fill. All the filled values are put into session
variables.
I want to prevent that he could click to the previous arrow of the browser
and then comes back to the form. Is that possible with asp.net?

Or, is it possible to clear the session when leaving the form page by
clicking the previous arrow?

Thanks
Eric
Hi Eric

this could do the trick

<script language="JavaScript">
if(history.length>0)
history.go(+1);
</script>

If user disabled javascript that wouldn't work and you would need to
look for another approach.

Hope this helps
Nov 9 '08 #2
Thanks a lot.
If you don't mind, could you tell me more (or refer) about the another
approach?
This is a good solution, but if possible, i would prefer a more waterproof
way.
Thanks

"Alexey Smirnov" <al************@gmail.comschreef in bericht
news:66**********************************@35g2000p ry.googlegroups.com...
On Nov 9, 11:26 am, "Eric" <e...@sdsclem.powrote:
Hi,

the user gets a form to fill. All the filled values are put into session
variables.
I want to prevent that he could click to the previous arrow of the browser
and then comes back to the form. Is that possible with asp.net?

Or, is it possible to clear the session when leaving the form page by
clicking the previous arrow?

Thanks
Eric
Hi Eric

this could do the trick

<script language="JavaScript">
if(history.length>0)
history.go(+1);
</script>

If user disabled javascript that wouldn't work and you would need to
look for another approach.

Hope this helps
Nov 9 '08 #3
On Sun, 09 Nov 2008 13:30:46 +0100, Eric <er*@sdsclem.powrote:
This is a good solution, but if possible, i would prefer a more
waterproof way.
Make sure that the input form does not get cached client-side:

Response.Cache.SetCacheability(HttpCacheability.No Cache)

Reject/redirect the user from the input form if the session variable is
already set:

if (Request.Session["foo"] != null) Response.Redirect("bar.aspx")

--
Joern Schou-Rode
http://malamute.dk/
Nov 9 '08 #4
"Eric" <er*@sdsclem.powrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>the user gets a form to fill. All the filled values are put into session
variables.
I want to prevent that he could click to the previous arrow of the
browser
and then comes back to the form. Is that possible with asp.net?

Or, is it possible to clear the session when leaving the form page by
clicking the previous arrow?

<script language="JavaScript">
if(history.length>0)
history.go(+1);
</script>

If user disabled javascript that wouldn't work and you would need to
look for another approach.

If you don't mind, could you tell me more (or refer) about the another
approach?
This is a good solution, but if possible, i would prefer a more waterproof
way.
This is a very common question - there are hundreds of articles about it on
the web:
http://www.google.co.uk/search?sourc...button+disable

There really is no 100% guaranteed method for this which will work in all
cases on all browsers on all platforms. Principally, this is because the
navigation buttons are part of the browser, not the web application...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 9 '08 #5
On Nov 9, 1:30*pm, "Eric" <e...@sdsclem.powrote:
Thanks a lot.
If you don't mind, could you tell me more (or refer) about the another
approach?
This is a good solution, but if possible, i would prefer a more waterproof
way.
Thanks
Another appoach is what Joern told you. You used a session for storing
the values, so you can check if session already has the values or not.
If session has stored values you would redirect to the next page.
There is another limit - session will not work if user has cookies
disabled. So, theoretically speaking, this is not a 100% solution. In
the same time you use session to store values and if session will not
work your form will not work as well. And if cookies are required to
use your site (it seems) then this maybe the best way to prevent
people from going back
Nov 9 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Marcel | last post: by
2 posts views Thread by Khor | last post: by
5 posts views Thread by Bill Davidson | last post: by

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.