Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am building a web Application using ASP.NET with Ajax functionality.
In my Application, I don't want the document scroll position to be changed after a patial postback. I have set maintainScrollPositionOnPostBack in Web.Config to "true". But, somehow it's not working.
XML
<pages maintainScrollPositionOnPostBack="true" >
      <controls>
        <add tagPrefix="ig" src="~/Controls/SOAGrid.ascx" tagName="ExcelGrid"/>
        <add tagPrefix="ig" src="~/Controls/IgMenu.ascx" tagName="IgMenu"/>
        <add tagPrefix="ig" src="~/Controls/IgList.ascx" tagName="IgList"/>
      </controls>
    </pages>


Then, I tried Javascript/Jquery to store the scrollTop position, and set it back after the postback is finished.

C#
var bodyScrollTop = 0;

function BeginRequestHandler(sender, args) {
    bodyScrollTop = $(document).scrollTop();
}

function pageLoad() {
   $(document).scrollTop(bodyScrollTop);
}


But, this is also not working. I found out there are some javascript methods namely scriptResource.axd which run after all my scripts. In this script, there is a code WebForm_AutoFocus which resets my document scroll position. Please suggest me a solution for this.
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900