Solved

Maintain scroll position on postback

Posted on 2014-12-18
1
518 Views
Last Modified: 2014-12-18
I have a aspx page that has controls nested in UpdatePanels where I need to maintain scroll position across postbacks. The page is inside a Master page, with  one main UpdatePanel, then an Ajax Tab Container. Inside the TabContainer is a gridview nested inside another gridview. I need to maintain scroll position in the inner gridview.

I have tried smartNavigation="true" maintainScrollPositionOnPostBack="true" in the page and in the web.config. I have also tried various JavaScript solutions that I have found. Nothing seems to affect the scroll at all. If I the page is visible above the TabContainer on scrolling, the page will go back to that point. If I click on items in the gridview with only the gridview visible on scrolling, it scrolls to the top of the TabContainer. The page knows it's in the TabContainer control, but not it's position.

This is the current JavaScript solution that I am trying, but again nothing seems to change the behavior.

<script type="text/javascript">
    //-------------------------------------------------------//
    // Maintain scroll position in given element or control
    //------------------------------------------------------//
    var xInputPanel, yInputPanel;
    var xProductPanel, yProductPanel;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender, args) {
        yInputPanel = $get('<%=gvManAcctNumr.ClientID%>').scrollLeft;
        yProductPanel = $get('<%=gvManAcctNumr.ClientID%>').scrollTop;
    }
    function EndRequestHandler(sender, args) {
        $get('<%=gvManAcctNumr.ClientID%>').scrollLeft = yInputPanel;
        $get('<%=gvManAcctNumr.ClientID%>').scrollTop = yProductPanel;
    }
</script

Open in new window

>
I have tried using various controls (TabContainer, TabPanels, Gridview, etc.) in the above code, but nothing changes. Has anybody done something like this or is it not possible?

It's very annoying to click on an item in a list of 50 and have it jump back the top of the page because the user has to scroll down to process the next item.
0
Comment
Question by:Jerry Miller
[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
1 Comment
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 0 total points
ID: 40508147
OK, so I wrapped the contents of the TabPanel in an UpdatePanel so it is only doing a partial postback and it now works. Something so simple and I have been beating my head against a wall all day on this one.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

623 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