General "previous page" feature saving state

J

Jeff

I need to place a "Previous Page" link on every page within my site and
a simple javascript:history.back() will not work because I need it to
capture the state of the page when I left it. For example, if I have
a page with some date controls so I can choose a date range and
postback the page. It then displays results based on that date range.
When I leave the page for another page, I would like to have the
Previous Page link take them back to the page with the same date range.

I know I can do this by storing these values in session but it then has
to be specific for every page and store every value manually. Is there
a way to store the previous pages state and then use it when going back
to that page? Maybe somehow using the viewstate?

Any ideas would be appreciated.

Thanks,

Jeff
 
P

Peter Bradley

It is very rare, when you have a series of data pages, that you are not
gathering information about objects that you have, or perhaps should have,
instantiated in the background on the server. These objects model the
business objects that your system is concerned with. The identification of
such objects should have come out in the design phase of your project
development: most people use UML these days.

Assuming that you have such objects, then it is a trivial matter to store
their state when the user performs some appropriate action, such as clicking
on a "Next >" button, or a "Store" button at points where the state needs to
be persisted in a database or on disk. The corollary of this is that if the
user does not perform that action, the state is as it was on leaving the
previous page.

You may also need to store an enumeration value, or some other convenient
device, in the object(s) indicating what the previous page was. This would
be the case where users do not have to travel through the application in any
particular order. You may find it easier to have a separate object that
holds this navigation state information, especially if you want to maintain
a history.

Thus, if you have a "< Back" button (that is a server control), then you can
read any necessary information from the server objects that you have, and
send the user to the required page. That page's Page_Load method can then
read the current state from the relevant objects.

You keep the relevant objects in scope by storing references to them in the
Session.

HTH


Peter
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top