When page loads, How can I go to the bottom of the page?

Posted on 2004-10-27
Last Modified: 2011-10-03
Every time I do a postback my page goes back to the top of the page.  My users have to keep scrolling down.  I have turned on Smart Navagation on my page but that has no effect.  Not sure why either.  My form pulls in alot of user controls.  On each post back it adds another user control to the bottom of the web form.  Thats the control I would want to have focus for lack of a better name.

Anyone got a suggestion on either how to set focus to a paticular User Control or how to make the page go to the bottom when it loads?

Thanks for your time!!!
Question by:accmats

    Expert Comment


    Put an anchor to the bottom of your page,
    <a name="bottom">
    and call your page with #bottom at the end.
    During the postbacks it should go to bottom anchor.

    This might work.

    Author Comment

    what would be the syntax of that #Bottom and would I put that in the page load event?

    Expert Comment

    no, just put after the adress on the link like
    LVL 35

    Expert Comment

    just use this javascript function:

    function scrollToCoordinates() {

    call it from body onLoad :

    <body onload="javascript:scrollToCoordinates()" MS_POSITIONING="FlowLayout">
    LVL 33

    Expert Comment

    nooo, don't use anchors!  You get the double-click effect when the page loads.  Use Javascript and the ScrollIntoView() function.
    LVL 35

    Accepted Solution

    add two hidden fields to the page, call then scrollx and scrolly. Then add the following javascript code:

    var IE = document.all?true:false;
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    document.onmousemove = getMouseXY;

    var tempX = 0;
    var tempY = 0;
    function getMouseXY(e) {
    if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
    else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
    if (tempX < 0){tempX = 0;}
    if (tempY < 0){tempY = 0;}  
    document.Form1.scrollx.value = tempX;
    document.Form1.scrolly.value = tempY;

    return true;
    function scrollToCoordinates() {

    Then call scrollToCoordinates from body onLoad:

    <body onload="javascript:scrollToCoordinates()" MS_POSITIONING="FlowLayout">

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Lean Six Sigma Project Manager Certification

    There are many schools of thought around successful project management, but few as highly regarded as the Six Sigma and Lean methods. With 37 hours of learning, this training will explain concrete processes for increasing efficiency and limiting wasted time and effort.

    Suggested Solutions

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    934 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now