views:

346

answers:

3

How to scroll to bottom of page when postback finish in asp.net?

I have many detail in page whan i clicking show detail in master detail this page show many data in my page so how to to scroll to bottom of page auto ?

A: 

You could register the a javascript to move the scroll to the position of some control that you want, like this:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            RegisterStartupScript("ScrollScript", "document.getElementById('objectId').scrollIntoView(true);");
        }
    }

Changing the objectId in the script for the Id of the object you want to scroll to.

Limo Wan Kenobi
A: 

Create an anchor on the page, then on onload:

window.location.href = "#myanchor"
MikeW
A: 

from Hosam Kamel's page

To maintain the scroll position for the large web page you can use on of these methods :

1- use Web.config page section <pages maintainScrollPositionOnPostBack="true" />

: this will maintains the scroll positions for all the web site pages.

2- in the page declaration <%@ Page MaintainScrollPositionOnPostback="true" %> : this will maintains the scroll position for this page only.

3- programmatically from code behind System.Web.UI.Page.MaintainScrollPositionOnPostBack = true; : this will maintains the scroll position for this page only (the same as page declration).

ram
How to use its i add <%@ Page MaintainScrollPositionOnPostback="true" %> but not work to bottom?
monkey_boys
that current scroll position?
monkey_boys
sorry, I misunderstood the problem. I had a similar situation where the user would scroll to the bottom of the page, do a post back and would lost the scroll position.Now I understand that the user directly should go to the bottom of the page after postback
ram