Back Button Issues

T

Tom wilson

I'm developing an application that is a benefits enrolment website.
The benefits can be of any type in any order as stored in a SQL
server. On each page is a Back and Next button. At a certain point
in the initialization of the app, I determine a navigational
structure; what benefit is first, second, etc., therefore, which page
to display first, second and so on.

In session memory I store an array of page URL's and a single value
called "ThisPage". So if "ThisPage" = 3, I look at URLs(3) and it'll
say something like "LTD.aspx". This is the Next button code:

URLs = Session("URLs")
Session("ThisPage") += 1
Response.Redirect(URLs(Session("ThisPage")))

This works better than I expected. I could have ALMOST used a single
page for everything. Anyways, this works flawlessly until someone
hits the Browser back button. We go back but since I didn't click MY
back button, the above values never get updated and the navigation is
thrown out of sync. I could 'browser back' 4 times from page 6 to
page 2 and my session tracking still thinks we're on page 6. If we
hit next it goes to Page 7, not 3.

How does one deal with this? Is there some way of knowing the user
hit the browser's back button so I could execute MY back button's code
and keep the navigation in sync?

Or are there better methods for dynamic navigation?

(I'd rather not disable the browser history and the browser back
button functionality, it seems sloppy to me)

Thanks! :)
 
B

Bruce Barker

store the current page idx in a hidden field or viewstate as its only
required on a postback (next or previous).

-- bruce (sqlwork.com)
 
S

shaun duke

Tom,
This is only a thought, and will generate some additional overhead, but
....
during the initialisation can you put a reverse lookup table into a
session variable.

Then onload query the reverse lookup to retrieve the pages order in the
navigation structure and
Reset Session("ThisPage") to the correct value.

Then when you your user hits back or whatever the navigation will be
kept in sync.
 
D

dan.c.roth

Solution to the Back button problem for IE 5.5 and above.

1) Get rid of the cache

Response.CacheControl = "no-cache";
Response.AddHeader("Pragma", "no-cache");

2) set SmartNavigation = true

Daniel Roth
MCSD.NET
 
T

Tom wilson

That made absolutely no difference. I can use the browser's back
button just as much with or without it.

Do I have to put this at the top of every page in the project?
 
T

Tom wilson

I put this in every page in the project. I can use the back button as
much as I please. Did I miss something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top