Solved

Maintain scroll position of DIV through postback in masterpage

Posted on 2010-09-22
2
1,123 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
2 Comments
 
LVL 15

Accepted Solution

by:
crisco96 earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

937 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

10 Experts available now in Live!

Get 1:1 Help Now