programatically scroll page to bottom?

Posted on 2006-05-23
Last Modified: 2010-08-05
Is there a way to scroll the page to the bottom (from a code-behind page)? 2003

Question by:ottenm
    LVL 4

    Expert Comment


    Author Comment

    It's close, but it also scrolls horizontally a few pixels.  Anyone know how to keep the horizontal scroll flush against the margin?

    More details (if needed):
    My form uses flow layout which positions the controls a few pixels in from the left border of the browser.  The js does scroll to the bottom of the page, but it also scrolls to the right, a few pixels away from the margin to the left edge of the control.  I've tried to move the control further to the left (using CSS left and margin-left) but 1) it gets cut off and 2) the js still scrolls to the rights.

    For convenience, here's the punchline from the (18 comment) sequence referenced above.  It will scroll your page to a particular control:

            Dim s As String = "<script language='javascript'>document.getElementById('" & _
                MyControlNearPageBottom.ClientID & "').scrollIntoView();</script>"
            Page.RegisterStartupScript("ScrollCode", s)


    Author Comment

    Works for me, any complaints?

    Page.RegisterStartupScript("ScrollCode", "<script language='javascript'>window.scroll(0,100000);</script>")

    Accepted Solution

    PAQed with points refunded (125)

    Community Support Moderator

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now