Jerry Miller
asked on
Maintain scroll position on postback
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" maintainScrollPositionOnPo stBack="tr ue" 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.
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.
I have tried smartNavigation="true" maintainScrollPositionOnPo
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
>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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.