Tip #75: Did you know…How to maintain scrollposition after post back?

2009/06 09 07:06

When web pages are posted back to the server, by default user is returned to
the top of the page. On a large web page, you might have a requirement to scroll
down the user automatically to the last position on the page.

MaintainScrollPositionOnPostBack page property can be used to achieve this 
in one of the following ways. 

  1. Application level: To set the property by default for all
    pages in the website, open web.config and add the attribute to the pages
    node.

  2. Page Level: for a particular page, open the aspx and set
    the property

    <%@ Page MaintainScrollPositionOnPostback="true" ...

  3. Code level: to set the property
    programmatically

    Page.MaintainScrollPositionOnPostBack =
    true;

Hope this helps.

Deepak Verma 

--转载请注明: http://www.jamesying.com/2009/06/09/tip%2375%3adidyouknowhowtomaintainscrollpositionafterpostback%3f/

发表回复

欢迎回来 (打开)

(必填)