Return to previous page

S

staeri

I use javascript:history.go(-1) to return to the previous page.

I've now found out that when returning to the previous page all
selections that the user made in dropdownlists are lost. How can these
be kept when returning?

I'm very grateful for fast response.

// S
 
P

Peter Bucher [MVP]

Hello Staeri

How do you return to the last Page?
If with "history.go(1);, all should work as expected,
because you are only navigating on the browser history.
 
S

Stan

I use javascript:history.go(-1) to return to the previous page.

I've now found out that when returning to the previous page all
selections that the user made in dropdownlists are lost. How can these
be kept when returning?

I'm very grateful for fast response.

// S

The previous data is lost because the browser has no way of retaining
it.

You have to use postback events to do the redirection and store the
data in session state.
 
S

staeri

Obviously. When you hit the Back button (either directly or in the above
code), the browser opens the previous page in exactly the same way as it was
previously opened - it has no way of "remembering" any client-side
modifications made to that page unless they were posted back...

Thank you for the answers!

I've stored the dropdownlist selections in sessions but is there a way
to set the dropdownlist selections to the session values when the page
is showed again when clicking the return button with
javascript:history.go(-1)? If it can be made without changing the url
I'm very happy because otherwise there are a lot changes I have to
make because of iframe etc.

// S
 
S

staeri

Sure. You just need to restore selection from the session in the Page_Load
event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net




Thank you for the answers!
I've stored the dropdownlist selections in sessions but is there a way
to set the dropdownlist selections to the session values when the page
is showed again when clicking the return button with
javascript:history.go(-1)? If it can be made without changing the url
I'm very happy because otherwise there are a lot changes I have to
make because of iframe etc.
// S- Dölj citerad text -

- Visa citerad text -

It looks like Page_Load isn't fired when returning to the page by
using javascript:history.go(-1). Is that correct?

// S
 
E

Eliyahu Goldin

This means the browser gets it from the cache. location.reload(true) will
always go to the server. You need to think how to combine both history and
location calls.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Sure. You just need to restore selection from the session in the Page_Load
event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net




Thank you for the answers!
I've stored the dropdownlist selections in sessions but is there a way
to set the dropdownlist selections to the session values when the page
is showed again when clicking the return button with
javascript:history.go(-1)? If it can be made without changing the url
I'm very happy because otherwise there are a lot changes I have to
make because of iframe etc.
// S- Dölj citerad text -

- Visa citerad text -

It looks like Page_Load isn't fired when returning to the page by
using javascript:history.go(-1). Is that correct?

// S
 
S

staeri

What is the purpose of using the back button ?

The intended use is to display the previous page as it was previously seen
by the user. You could also prevent this page from being cached browser side
so that it is fetched again from the server (and possibly then updated).

Or perhaps should you implemnt your own link. What is the meaning of using
the back button in your case ?

--
Patrice

<[email protected]> a écrit dans le message de groupe de discussion :
(e-mail address removed)...







- Visa citerad text -

The purpose of the back button is to display the previous page as it
was previously seen by the user. How I go back to the previous page
doesn't matter as long as the url isn't changed.

// S
 
S

Stan

The purpose of the back button is to display the previous page as it
was previously seen by the user. How I go back to the previous page
doesn't matter as long as the url isn't changed.

// S- Hide quoted text -

- Show quoted text -

There is another approach to this that might be helpful.

Your problem seems to be that you are going away from the first page
when the user initiates a request for the second page. Hence the
browser reloads the first from scratch when you return to it (either
from the local cache or from the server but will make no difference).

Session state can be used to overcome this but an easier solution is
to use a single page with a MultiView control with two Views (one view
for each formerly separate page). That way ViewSate will retain the
content of any web server controls in both views because switching
between then will only occur on postback (but use a postback command
button to do the going back not one that does it via the browser using
JavaScript).

HTH
 
S

staeri

There is another approach to this that might be helpful.

Your problem seems to be that you are going away from the first page
when the user initiates a request for the second page. Hence the
browser reloads the first from scratch when you return to it (either
from the local cache or from the server but will make no difference).

Session state can be used to overcome this but an easier solution is
to use a single page with a MultiView control with two Views (one view
for each formerly separate page). That way ViewSate will retain the
content of any web server controls in both views because switching
between then will only occur on postback (but use a postback command
button to do the going back not one that does it via the browser using
JavaScript).

HTH- Dölj citerad text -

- Visa citerad text -

Thank you for the suggestion, Stan! Will there be any performance
degradation when using a MultiView? Will both views be loaded
initially or only the first view?

// S
 

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,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top