Move to anchor after ASP.Net AJAX postback

Last post 08-06-2009 10:01 PM by lafong. 3 replies.

Sort Posts:

  • Move to anchor after ASP.Net AJAX postback

    10-11-2008, 1:53 AM
    • Contributor
      6,599 point Contributor
    • anzer
    • Member since 10-19-2004, 4:00 AM
    • UAE
    • Posts 1,319

    Put the below code at the end of the aspx page

    <script language="javascript" type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(OnEndRequest);
    function OnEndRequest(sender,args)
    {
    window.location.hash = '#MOVEHERE'; //MOVEHERE is the anchor name
    }
    </script>

    If you want to show top of the page instead of move to anchor use window.scrollTo(0,0); instead of window.location.hash = '#MOVEHERE';

    If you are looking  for how to move to anchor in a usual postback check this http://forums.asp.net/t/1311972.aspx

     

     

    If this post was useful to you, please mark it as answer.

    ClientSideAsp.Net | Blog
  • Re: Move to anchor after ASP.Net AJAX postback

    10-11-2008, 7:57 AM
    • All-Star
      36,855 point All-Star
    • rtpHarry
    • Member since 10-01-2006, 12:51 PM
    • Lincoln, England
    • Posts 5,951

    And if you wanted to make the transition a bit slicker you could throw in some JQuery code, microsofts new bestest buddy in the javascript world.

    A plugin like the one linked below would animate a smooth scroll down to the anchor rather than a standard jump.

  • Re: Move to anchor after ASP.Net AJAX postback

    10-11-2008, 8:03 AM
    • Contributor
      6,599 point Contributor
    • anzer
    • Member since 10-19-2004, 4:00 AM
    • UAE
    • Posts 1,319

    Thank you fort the tip..

    Yeah JQuery + Asp.Net AJAX is simply great... http://encosia.com/ has some really great articles on that subject

    If this post was useful to you, please mark it as answer.

    ClientSideAsp.Net | Blog
  • Re: Move to anchor after ASP.Net AJAX postback

    08-06-2009, 10:01 PM
    • Member
      2 point Member
    • lafong
    • Member since 07-06-2009, 2:48 AM
    • Posts 1

     thank you very much...

    Filed under:
Page 1 of 1 (4 items)