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

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
Published: Wednesday, January 26, 2000

Rewiring the Back Button, Part 2

By TJ Sylvester

  • Read Part 1

  • In Part 1 we discussed how to create the first two pages of the system. In this part, we'll look at creating the last two pages!

    - continued -

    I think you'll find that the third and fourth pages are fairly simple. The third page, redirect.asp is responsible for handling any form processing. For example, if you have your users enter a value in form.asp that needs to be inserted into a database, in the third page, redirect.asp, this processing needs to occur. redirect.asp also redirects the user to the confirmation page after any needed form processing is completed. A small note, the redirect.asp page is set to refresh to confirmation.asp in one second, which is a small delay. The reason behind this: Internet Explorer. If you set the time to zero seconds, it will ignore redirect.asp and head straight back to form.asp.

    <%@ Language=VBScript %>
    Response.Buffer = True
    ' checks for empty session variable, 
    ' otherwise display the page which refreshes to confirmcation.asp
    if isEmpty(Session("GoForward")) then
    	Response.Redirect "default.asp"
        'Perform needed form processing here
        '(i.e., database entries)
    	<META HTTP-EQUIV="Refresh" CONTENT="1;URL=confirmation.asp">
      The form is being processed.  Please be patient.

    The fourth page (confirmation.asp) will provide a confirmation of the form submission. This page simply displays a Thank You message, or some sort of confirmation.

    <%@ Language=VBScript %>
    Response.Buffer = True
    ' checks for empty session variable,
    ' and redirects to main page
    if isEmpty(Session("GoForward")) then
    	Response.Redirect "default.asp"
    ' if session variable is present, display this code
    <table width="400">
          Thank you. Your request has been submitted to the IT 
          Department. Your confirmation number is <b>xxx</b>. 
          Please refer to this number when contacting the IT Department. 
          You can view the status of your request by using the 
          status page.</p>
    end if
    ' this will kill the session variable
    ' You could also use:
    ' Session("GoForward") = ""

    Now that you have the code, try it out. Open default.asp and click the form link. On the form.asp page, click submit. If you noticed, the form processes itself, then redirects to redirect.asp.

    The purpose of redirect.asp is to create an HTML page for the back button to hit while a META tag to refresh to confirmation.asp. Using the META tag to refresh to another page will load a fresh instance of that page.

    Confirmation.asp now checks for the session variable. If it is present, it will display the confirmation and the kill the session variable. If a user clicks the back button, redirect.asp is loaded up which will send them directly back to confirmation.asp. This time, however, the session variable is empty and we are redirected to default.asp.

    Happy Programming!

  • Read Part 1


  • Try out the example!
  • Download the source code in text format

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