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

Back button question

I have an ASP.Net app and I'm trying to prevent the user from hitting the
back button to get back to page2.aspx from page3.aspx. I put this code in
page_init, page_load and page_prerender and it never fires except when I'm
coming into the page or posting back. When I go 'back' to the page it never
fires.

Dim sLastPage As String = Request.ServerVariables("HTTP_REFERER")
If sLastPage.IndexOf("Page1.aspx") < 5 And
sLastPage.IndexOf("Page2.aspx") < 1 Then
' if they did not come from Page1 or Page2 then send
' them back to where they came from
Response.Redirect(Request.ServerVariables("HTTP_RE FERER"))
End If

Thanks for any help,
DougS
Nov 19 '05 #1
3 967

"DougS" <do**@nospam.com> wrote in message
news:O1***************@TK2MSFTNGP15.phx.gbl...
I have an ASP.Net app and I'm trying to prevent the user from hitting the
back button to get back to page2.aspx from page3.aspx. I put this code in
page_init, page_load and page_prerender and it never fires except when I'm
coming into the page or posting back. When I go 'back' to the page it never
fires.

Dim sLastPage As String = Request.ServerVariables("HTTP_REFERER")
If sLastPage.IndexOf("Page1.aspx") < 5 And
sLastPage.IndexOf("Page2.aspx") < 1 Then
' if they did not come from Page1 or Page2 then send
' them back to where they came from
Response.Redirect(Request.ServerVariables("HTTP_RE FERER"))
End If

Thanks for any help,
DougS


The thing you must understand about most browser back buttons is that they
reload the client-side html from their own cache. It doesn't normally cause
a post-back to the server. Because of this, you don't get the server-side
events (not post-back). So, you'd either have to check when the client
re-submits the web page, or something similar.

HTH,
Mythran

Nov 19 '05 #2
Take a look at this article:
http://www.dotnetbips.com/839A3429-2...?articleid=288

I think it only works for IE though.

-Raul
Nov 19 '05 #3
Thanks a lot, that works well.
Doug
"Raul Macias" <ra*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Take a look at this article:
http://www.dotnetbips.com/839A3429-2...?articleid=288

I think it only works for IE though.

-Raul

Nov 19 '05 #4

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

Similar topics

5
by: Mel | last post by:
how can i have a "Prev" button in my form to take me back to previous page WITHOUT Javascript ? thanks Mel
4
by: PiedmontBiz | last post by:
Greetings I have written an online survey with 110 questions. I use javascript to cycle thru all the questions which are displayed in an iframe. I keep track of the question number using a...
25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
1
by: Peter D. Dunlap | last post by:
Hello, I realize that this may not be the best place to ask this question, through the application is asp.net. I also realize that questions about disabling the back button are generally met...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
8
by: Shimon Sim | last post by:
Hi, Every time I write ASP.NET application I have the same problem - Back button on the browser is my enemy. I have to tell client avoid using "Back" button and if you use it make sure to refresh...
7
by: Sridhar | last post by:
Hi, I have a question regarding the Page_Load method and Back Button of Internet explorer. I have created a webform. In that webform I have several Text Boxes. Also I have two buttons. When I...
7
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the...
1
by: confusedofphp | last post by:
Hi all, Im very new to php. Currently im creating an online exam system which uses php and mysql as the database. I have registration and login page which works pretty fine. I had problem when it...
5
by: agun | last post by:
Hi, guys sorry if this kind of question had been asked before and kinda newbie question. coz i'm new to programming and just couldn't figure it out yet... My problem is: I have a form that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.