Handle the issue that the rollback of the scroll bar remains unchanged in the master page and AJAX Environment

Source: Internet
Author: User

Handle the issue that the rollback of the scroll bar remains unchanged in the master page and AJAX Environment

When dealing with the scroll bar of the TreeView list, I found that many popular processing methods have no effect, but it is not feasible to use this popular method in the Master Ajax environment. As a result, self-reliance is achieved through the following code:

Add this JS section on the page:

<Script type = "text/javascript">

Var disPostion = 0;

Function SaveScroll (){

DisPostion = TaskListDivID. scrollTop;

}

Function RestoreScroll (){

Sys. WebForms. PageRequestManager. getInstance (). add_endRequest (EndRequestHandler );

}

Function EndRequestHandler (sender, args ){

TaskListDivID. scrollTop = disPostion;

}

</Script>

Use this DIV to hide the content that requires such a scroll bar (such as TreeView ).

<Div id = "TaskListDivID">

Treeview and other scroll bar content

</Div>

If the cs code is processed in the background:

// This code starts to solve the problem of reset of the scroll bar.

ScriptManager. RegisterOnSubmitStatement (this. Page, this. Page. GetType (), "SavePanelScroll", "SaveScroll ();");

If (this. IsPostBack)

{

ScriptManager. RegisterStartupScript (this. Page, this. Page. GetType (), "SetPanelScroll", "RestoreScroll ();", true );

}

// End

Note: var disPostion = 0; AJAX UpdatePanel does not reset the response page.

In addition, as I implemented this in Ascx, because the pages that use ajax need ScriptManager, and they are already used in the master page, they cannot be added again, the Proxy version is used.

<Asp: ScriptManagerProxy ID = "ScriptManagerProxy1" runat = "server">

</Asp: ScriptManagerProxy>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.