Asp.Net Maintain Scroll Position On Postback In Google Chrome

Maintain Scroll Position On Postback In Google Chrome Browser Using Asp.Net.

In one of my previous posts i describe Maintaining Scroll Position After Postback. But this method doesn't work with Google Chrome browser.

So we need to go with any of two methods mentioned below.

Write following code in Page_Load event of page.

protected void Page_Load(object sender, EventArgs e)
        MaintainScrollPositionOnPostBack = true;

Right click on solution explorer > Add New Item

Select Browser File and add it to App_Browsers folder.

Add MaintainScrollPositionOnPostback capability to this browser file as written below.

   <browser refID="Mozilla">
       <capability name="supportsMaintainScrollPositionOnPostback"
                   value="true" />

Build and run the code and it should work with Google chrome.

We can use scrollsaver javascript file to maintain scroll position In Chrome.

Just add this file in root of solution and add reference to it in head section of page.

   1:  <script src="scrollsaver.min.js" type="text/javascript">
   2:  </script>

hope this helps.

If you like this post than join us or share


Anonymous said...

Excellent solution using javascript method, works well !

Find More Articles