Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
How do i maintain DIV scroll Position on Postback without using Update Panel.

Thanks and Regards
Posted 16-Jun-11 0:50am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Have a look at this article: JavaScript Access to Page Controls after Ajax Update (via Update Panel)[^]
Sorry for not reading 'not update panel'
You can try,
1. Page.MaintainScrollPositionOnPostBack = true;
2. You can track the scroll position before the postback and then when the page is loading, on page load using javascript you can set back the scroll.
Monjurul Habib at 16-Jun-11 18:41pm
he needs the solution without update panel.anyway nice link.
S Mewara at 16-Jun-11 23:38pm
My Bad. I read it as Update panel thing. :doh:
Thanks Monjural for telling me that. Updated the answer to make some sense now. :)
Monjurul Habib at 17-Jun-11 4:14am
my 5 for the advice.
S Mewara at 17-Jun-11 4:45am
AshishChaudha at 5-Jan-13 6:28am
my +5!
Sandeep Mewara at 5-Jan-13 11:40am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Firstly, I would suggest using:
Page.MaintainScrollPositionOnPostBack = true;
in your PageLoad event to maintain page position for your whole page.
Now, for the div question. I found a nice solution to your question here:[^]
I changed it a bit so to work with hiddenfield and not cookie. Below is the result.
<script type="text/javascript">
        window.onload = function () {
            var h = document.getElementById("<%=keep.ClientID%>");
            document.getElementById("divTest").scrollTop = h.value;
      function SetDivPosition(){
        var intY = document.getElementById("divTest").scrollTop;
        var h = document.getElementById("<%=keep.ClientID%>");
        h.value = intY;
Below is the starting tag of the div you want to maintain.
<div önscroll="SetDivPosition()" id="divTest">
- "divTest" is the name of the div you wish to maintain
- "keep" is the name of the hidden field I used
Tested with IE 8, Firefox 4 and Chrome 12.
Hope it helps!
SushantSundar at 10-May-12 5:51am
Thanks a ton. Badly needed it.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

var xPos, yPos;
       var prm = Sys.WebForms.PageRequestManager.getInstance();

       function BeginRequestHandler(sender, args) {

           yPos = $('#<%=divgvlocation.ClientID %>').scrollTop();
       function EndRequestHandler(sender, args) {
           $('#<%=divgvlocation.ClientID %>').scrollTop(yPos);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 389
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119

Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid