Solved

ASP.NET AJAX Maintain page vertical scroll position after redirect

Posted on 2012-03-11
2
815 Views
Last Modified: 2012-03-12
I have a search page on my site.  The user selects search criteria from cascading drop-downs, then clicks the search button and the results are displayed in a gridview on the same page.  All of this occurs inside an AJAX update panel.  When a user clicks an item in the results grid, they are redirected to a details view page.

I am using the AJAX script manager history function for storing the search info and grid page index, and this is working great- when the user clicks the browser's 'back' button, the page returns to the correct drop-down selections, results, and grid page index.

The one thing it does not do is retain the vertical scroll position of the page, so that when the user clicks the 'back' button to return to the search page, it returns to the vertical position they left it at.

This is where I need help- how can I grab the search page's vertical scroll position when the user is redirected to the details page, and restore it when the user clicks the 'back' button from the details page?
0
Comment
Question by:cmerlo1
2 Comments
 
LVL 22

Accepted Solution

by:
Mrunal earned 500 total points
Comment Utility
There is really no direct mechanism available for this.
So you have to do something extra.
Like, you can do this by storing scroll value into cookies and set again that page's scroll position to that one.

This you can achieve by JavaScript:

1. http://stackoverflow.com/questions/1086825/back-button-scroll-position

2. http://wiki.asp.net/page.aspx/1667/maintain-panel-scroll-position-in-ajax-update-panel/
0
 

Author Closing Comment

by:cmerlo1
Comment Utility
That did the trick!  I knew I needed Javascript- just didn't know the best way to implement it.  The cookies work perfectly.  Many thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now