When you think ASP, think...
Recent Articles xml
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips
spgif spgif

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
spgif spgif
ASP ASP.NET ASP FAQs Feedback topnav-right
Print this page.
Published: Wednesday, January 26, 2000

Rewiring the Back Button

By TJ Sylvester

Often there is a need for a form to "expire". Once a user submits a form, if they attempt to navigate back to the expired form (via the back button), they will instead be rerouted to an ASP page other than the expired form. Netscape supports a cache feature in the META tags to support this, but Internet Explorer does not. A simple work around is available for applications that must have this.

- continued -

This article will not go into great detail of an application for this work around, but merely to steer you into the right direction.

The work around consists of four pages. The first page is the default page (default.asp). Often this is the page you would want your users to return to. default.asp will contain a simple hyperlink to the ASP page that contains the form you would like your users to fill out. default.asp might contain the following simple code:

<html lang="en"> <head> <meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> </head> <body> <p>Opening Page</p> <p><a href="form.asp">Let's go to the form</a></p> </body> </html>

The second page, form.asp, would display the form to the user. This ASP page also needs to determine whether or not the user has returned to it from hitting the back button or not. If they have (that is, the user has already entered the form information once before, and the form has "expired"), then the user needs to be redirected to a different ASP page (default.asp in this example).

<%@ Language=VBScript %>


Response.Buffer = True

' sets header and footer

dim header, footer

header = "<HTML>" & VBCrLf

header = header & "<HEAD>"  & VBCrLf

header = header & "</HEAD>" & VBCrLf

header = header & "<BODY>" & VBCrLf

footer = "</BODY>" & VBCrLf

footer = footer & "</HTML>"

if NOT isEmpty(Request.Form("searchRequestSubmit")) then

	' process code and sub routines here

	' code to set session variable and redirect to confirm.asp

	Session("GoForward") = "True"

	Response.Redirect "redirect.asp"


	Response.Write header

	Response.Write "<form name=""searchRequest"" action=""form.asp"""

	Response.Write " method=""post"">" & VBCrLf

	Response.Write "<p>Please enter confirmation number</p>"

	Response.Write VBCrLf

	Response.Write "<input type=""text"" name=""searchCriteria"" "

	Response.Write "size=""5"">" & VBCrLf

	Response.Write "<input type=""submit"" value=""Search"" "

	Response.Write "name=""searchRequestSubmit"">" & VBCrLf

	Response.Write "</form>" & VBCrLf

	Response.Write footer

end if


Now that we've looked at how to create the first two pages, in Part 2 we'll look at how to create the remaining two pages!

  • Read Part 2

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article