UpdatePanel + TreeView + CSS Adapters dont work?

Last post 04-26-2008 10:06 AM by gselec. 3 replies.

Sort Posts:

  • UpdatePanel + TreeView + CSS Adapters dont work?

    03-01-2007, 9:00 AM
    • Loading...
    • PaulTAG
    • Joined on 01-05-2007, 2:32 PM
    • UK
    • Posts 43

    Hi There

    I have been developing an interface which uses a TreeView on the left, and a main panel on the right.

    During development everything has been fine.  I implimented CSS Adapters, and had all events firing correctly.  basically when you select a node in the tree on the left, the content on the right changes.  Simple.

    However, I have now wrapped my treeview and main panel in UpdatePanels.  I have setup the triggers accordingly.

    If I select items in the main panel (ie breadcrumbs in the bread crumb trail) the treeview acts accordingly.

    However, if I select nodes in the tree, my main panel doesnt update.  I set a breakpoint in my code behind to check if the select in event in the tree is being fired.  There is a post back happening, as the Page_Load event is fired,  however my Select node event is not fired.

    I removed the CSS adapters, and this functionality works correctly.

    So there is some problem between UpdatePanel and Treeview with CSS adapter.

    Could it be that the adapted treeview needs to use the event OnAdaptedSelectedNodeChanged, but I cant add this as a trigger for the UpdatePanel on the right hand side.

    Has anyone else has a problem like this?

    Thanks

    PaulTAG 


    Sincerely,
    PaulTAG
    C# Software Developer
  • Re: UpdatePanel + TreeView + CSS Adapters dont work?

    03-01-2007, 9:15 AM
    Did you register the css friendly adapters java script files with the script manager?
  • Re: UpdatePanel + TreeView + CSS Adapters dont work?

    03-01-2007, 10:59 AM
    • Loading...
    • PaulTAG
    • Joined on 01-05-2007, 2:32 PM
    • UK
    • Posts 43

    Hi There

    Yes the Javascript for the treeview adapter has been registered.

    I have since found out that the TreeView control is not supported for use inside an UpdatePanel.

    It just seems strange to me that the Selected Node Changed event isnt fired for an adapted treeview inside an UpdatePanel, but a Non Updated treeview does seem to fire that event.


     


    Sincerely,
    PaulTAG
    C# Software Developer
  • Re: UpdatePanel + TreeView + CSS Adapters dont work?

    04-26-2008, 10:06 AM
    • Loading...
    • gselec
    • Joined on 04-25-2008, 3:08 AM
    • Posts 12

    [updatepanel , treeView , position , state , postBack , hiddenfiled]

    put a treeView in a panel, it will show a scrollBar; when click then treeView, it will postBack,how to restore the position?

    ------------------------------------------------------------------------------------------------------------------------

    1:in common asp page: aspx

    <script language="javaScript">

     function loadEvent()
            {
                //tree在postBack时,显示在页面中的位置会移动,注册客户端脚本处理。加在body onload="loadEvent()"
                try
                {   //hf_SelectedNode tv_Main_SelectedNode 自动生成的hiddenField
                    var s="";   //tv_Main_Data.selectedNodeID.value;        //自动生成的java Object
                    if (s=="" || s==null) s="tv_Main_SelectedNode";
                    var elem = document.getElementById(s);          //tv_Main_SelectedNode
                    if(elem != null )
                    {
                        var node = document.getElementById(elem.value);
                        if(node != null)
                        {
                            node.scrollIntoView(false);             // true:页面顶部
                            //document.getElementById('div_Tree').scrollLeft = 0;
                        }
                    }
                }
                catch(oException)
                {}
            }

    </script>

    .....

    <body onload="loadEvent()" >

     ...

    <asp:Panel ID="panel_Tree" runat="server" ScrollBars="Both" Style="width:100%; height:100%"
                                <asp:TreeView ID="tv_Main"  runat="server" OnSelectedNodeChanged="tv_Main_SelectedNodeChanged" Width="300px">
                                    <Nodes>
                                        <asp:TreeNode Text="新建节点" Value="新建节点11"></asp:TreeNode>
                                        <asp:TreeNode Text="新建节点" Value="新建节点12"></asp:TreeNode>
                                  </nodes>

                               </asp:treeView>

    </asp:panel>

    ------------------------------------------------------------------------------------------------------------------------

    2:in ajax-updatePanel is hard, my way is record in client-cookie(thanks eric), aspx:

    </script language="javaScript">

    function loadEventCookie()
            {
                var strCook = document.cookie;
                document.title=strCook;
                if(strCook.indexOf("!~")!=0){
                    var intS = strCook.indexOf("!~");
                    var intE = strCook.indexOf("~!");
                    var strPos = strCook.substring(intS+2,intE);
                    document.getElementById("panel_Tree").scrollTop = strPos;
                }
            }
            function setDivPosition()
            {
                var intY = document.getElementById("panel_Tree").scrollTop;
                document.title = intY;
                document.cookie = "yPos=!~" + intY + "~!";
            }
        </script>

    .........

    <asp:Panel ID="panel_Tree" runat="server" ScrollBars="Both" Style="width:100%; height:100%"
                                    onscroll="setDivPosition()" onmouseup="loadEventCookie()" onmouseover="loadEventCookie()" >
                                <asp:TreeView ID="tv_Main"  runat="server" OnSelectedNodeChanged="tv_Main_SelectedNodeChanged" Width="300px">
                                    <Nodes>
                                        <asp:TreeNode Text="新建节点" Value="新建节点11"></asp:TreeNode>
                                        <asp:TreeNode Text="新建节点" Value="新建节点12"></asp:TreeNode>
                                        <asp:TreeNode Text="新建节点" Value="213"></asp:TreeNode>

                                    </Nodes>
                                    <SelectedNodeStyle BackColor="LimeGreen"/>
                                </asp:TreeView>
                            </asp:Panel>

     

    it works good! haha!

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter