?
Solved

Maintain scroll position of DIV through postback in masterpage

Posted on 2010-09-22
2
Medium Priority
?
1,143 Views
Last Modified: 2012-05-10
I have a master page with an update panel wrapping up the content template. In one of my pages  I have a grid view that is residing in a Div that utilizes the overflow method to produce scroll bars. I need to be able to retain the scroll position through post back. I have tried about a dozen 'solutions' to this (all JS) and none of them seem to work in conjunction with the master page. Please help! ><
0
Comment
Question by:Knance
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
crisco96 earned 2000 total points
ID: 33736121
The reason why all the solutions didn't work with the master page is because if you view the html of your page you will see the controls that you made runat="server" have kind of a strange ID (something like ctrl0_bla_ControlID) what you need to do is when referencing the control in javascript is use <%=ControlID.ClientID%> which will return that strange ID for you.
0
 

Author Comment

by:Knance
ID: 33736205
I think by just posting here it makes the answer 10x easier to find.

As with most of these solutions after your script manager add :

                     <script type="text/javascript">
                         var xPos, yPos;
                         var prm = Sys.WebForms.PageRequestManager.getInstance();
                         prm.add_beginRequest(BeginRequestHandler);
                         prm.add_endRequest(EndRequestHandler);
                         function BeginRequestHandler(sender, args) {
                             try {
                                 yPos = $get('ctl00_MainContent_scroll').scrollTop;
                             }
                             catch (err) { }
                         }
                         function EndRequestHandler(sender, args) {
                             try {
                                 $get('ctl00_MainContent_scroll').scrollTop = yPos;
                             }
                             catch (err) { }
                         }
                        </script>


Check your source for your div id...mine was 'scroll' in code but as you see during runtime master page changes that a bit....hope this helps anyone else having issues.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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