0

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! ><

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by MichaelWClark
0

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.

Edited by Dani: Formatting fixed

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.