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>