views:

30

answers:

1

Hello everybody. i am using asp.net 4.0 iis 7.5 microsoft visual studio 2010

what i want is keep whole page (browser) scroll position (not a div or panel) when asynchronous postback happened (update panel)

how can i do this

actually i had a function which can keep div scroll bar position after postback like this

       <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) {
            xPos = document.getElementById('Main').scrollLeft;
            yPos = document.getElementById('Main').scrollTop;
        }
        function EndRequestHandler(sender, args) {
            document.getElementById('Main').scrollLeft = xPos;
            document.getElementById('Main').scrollTop = yPos;
        }
    </script>

bu i could not find browser scroll bar id to get its values to get with document.getElementById

thanks for answers

+2  A: 

asp.net has @page directive property called MaintainScrollPositionOnPostBack

hope this will help

lakhlaniprashant.blogspot.com
this does not work for asynchronous postbacks
PokemonCraft
ok, i think this is the right one: http://forums.asp.net/t/1300961.aspx and also http://stackoverflow.com/questions/799852/page-moves-to-top-on-postback-of-control-in-updatepanel
lakhlaniprashant.blogspot.com
thanks for answer but did not solve problem for firefox :(
PokemonCraft
can you please share your code?
lakhlaniprashant.blogspot.com
`MaintainScrollPostitionOnPostBack` works just fine in FireFox. Are you having an issue when trying to combine with another component, say the notorious UpdatePanel, for example?
rlb.usa