简体   繁体   English

树视图层次结构在“更新”面板中无法正常工作

[英]tree view Hierarchy is not working properly in side the Update panel

I am using a Tree View Hierarchy inside the UpdatePanel . 我在UpdatePanel使用树视图层次结构。 The ASP.NET code is: ASP.NET代码是:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:TreeView ID="HierarchyTreeView" runat="server" meta:resourcekey="HierarchyTreeViewResource1" EnableViewState="true"></asp:TreeView>
    </ContentTemplate>
</asp:UpdatePanel>

and on code behind i am writing 在我正在编写的代码后面

protected override void OnInit(EventArgs e)
{
        base.OnInit(e);
        HierarchyTreeView.PathSeparator = CaseListPresenter.PathSeparator;
        HierarchyTreeView.TreeNodePopulate += new TreeNodeEventHandler(HierarchyTreeView_TreeNodePopulate);
        HierarchyTreeView.SelectedNodeChanged += delegate {
            Presenter.CancelChangeFlag(); 
            Presenter.SelectedNodeChanged(); 
            CheckPreview(); 
        };
}

If I am using TreeView outside the UpdatePanel my OnInit is working well. 如果我在UpdatePanel之外使用TreeView则我的OnInit运行良好。 But, if I am using TreeView inside the UpdatePanel , it is not working properly. 但是,如果我在UpdatePanel使用TreeView ,它将无法正常工作。 I want to maintain the scroll position of my tree view 我想保持树形视图的滚动位置

TreeView is not fully supportive with update panel. TreeView不完全支持更新面板。

we can maintain the scroll position by using following script: 我们可以使用以下脚本来保持滚动位置:

<script language="javascript" type="text/javascript">
         var IsPostBack = '<%=IsPostBack.ToString() %>';
         window.onload = function() {
             var strCook = document.cookie;
             if (strCook.indexOf("!~") != 0) {
                 var intS = strCook.indexOf("!~");
                 var intE = strCook.indexOf("~!");
                 var strPos = strCook.substring(intS + 2, intE);
                 if (IsPostBack == 'True') {
                     document.getElementById("<%=Panel4.ClientID %>").scrollTop = strPos;
                 }
                 else {
                     document.cookie = "yPos=!~0~!";
                 }
             }
         }
         function SetDivPosition() {
             var intY = document.getElementById("<%=Panel4.ClientID %>").scrollTop;
             document.title = intY;
             document.cookie = "yPos=!~" + intY + "~!";
         }  

</script>

call the setDivPosition() on ur Panel4 在ur Panel4上调用setDivPosition()

Now finally i got the solution with this.. 现在终于我有了解决方案了。

Maintain Panel Scroll Position On Partial Postback ASP.NET 在部分回发ASP.NET上维持面板滚动位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM