Search code examples
c#javascriptasp.netjqueryajaxcontroltoolkit

Automatically page scrolling down in asp.net


I have a problem while opening asp.net page. on post back my page scrolling to the middle of the page. Page contains one ModalPopupExtender and so many javascripts. I think the page focusing on this ajax control while page load. There is no javascript function related to "animation" or "scroll" to scroll page.I tried below code to fix

         $(document).ready(function() {
        document.getElementById('staticcontrols').scrollIntoView(false);
          });"

In mozilla FX its working but not in IE. Please help me.

Thanks in advance.


Solution

  •     //JQUERY library needed
        //SOURCE
          <script type="text/javascript" src="../Styles/Cjs/jquery-1.6.4.min.js"></script>
          <script type="text/javascript">
          function main() {
                             $('html, body').animate({ scrollTop: 340 }, 'slow');
                          };
          </script> 
    
        //C#
    
        page_load
        {
         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>main();</script>", false);
        }
    
    //JQUERY library
    https://jquery.com/download/