Using TreeView in 2025v2 399

Posted by: enrique.pv-ext on 11 May 2026, 7:30 am EST

  • Posted 11 May 2026, 7:30 am EST - Updated 11 May 2026, 7:40 am EST

    Hi,

    Migrate from 2010v1 to 2025v2 399 in ASP.NET WebForms NET Framework 4.8.1.

    Using C1TreeView from C1.Web.Wijmo.Controls.48.dll

    My legacy code:

    <asp:Panel ID="PanelTreeViewColumns" runat="server" ScrollBars="Auto" Height="90%" Width="100%" style="overflow:hidden"
            BackColor="" BorderWidth="1px" BorderStyle="None" BorderColor="Black" EnableTheming="True">
            <cc1:C1TreeView ID="C1TreeViewColumns" style="disabled:disabled" runat="server" UseEmbeddedVisualStyles="True" AutoPostBack="false" 
                    VisualStyle="Office2007Blue"  OnClientNodeClicked ="C1TreeViewColumns_OnClientNodeClicked"  ShowCheckBoxes="false" AutoCheckNodes="False">
            </cc1:C1TreeView>
                <%--AutoPostBack="true" OnNodeClicked="C1TreeViewColumns_NodeClicked"--%>
        </asp:Panel>	 
    
    
    
       <div id="tree2" class="" style=" background-color:Transparent; float:left; margin-right:10px; height:500px; width: 400px">           
           <asp:UpdatePanel ID ="UpdatePanelTree2" runat="server">
               <ContentTemplate>         
                   <asp:Panel ID="Panel5" runat="server" ScrollBars="None" Height="90%" Width="100%" BackColor="Transparent" BorderWidth="1px" BorderStyle="None" BorderColor="Black" 
                       EnableTheming="True">
                       <cc1:C1TreeView ID="C1TreeView2" runat="server" AutoPostBack="false"
                           AllowTriState="True" ShowCheckBoxes="true" AutoCheckNodes="true"
                           VisualStyle="Office2007Blue"                                         
                           VisualStylePath="~/C1WebControls/VisualStyles">
                       </cc1:C1TreeView>
                   </asp:Panel>
               </ContentTemplate>
           </asp:UpdatePanel>
       </div>                
       <div id="divTree3" class="" style=" background-color:Transparent; float:left; margin-right:10px; height:500px; width: 400px">                    
           <asp:UpdatePanel ID ="UpdatePanelTree3" runat="server">
               <ContentTemplate>
                   <asp:Panel ID="Panel6" runat="server" ScrollBars="None"
                       Height="90%" Width="100%"
                       BackColor="Transparent" BorderWidth="1px" BorderStyle="None" BorderColor="Black" 
                       EnableTheming="True">
                       <cc1:C1TreeView ID="C1TreeView3" runat="server" AutoPostBack="false" 
                           AllowTriState="True" ShowCheckBoxes="true" AutoCheckNodes="true"
                           OnClientNodeCheckChanged="C1TreeView3_NodeClicked"  
                           VisualStyle="Office2007Blue" 
                           VisualStylePath="~/C1WebControls/VisualStyles">
                       </cc1:C1TreeView>
                   </asp:Panel>
               </ContentTemplate>
           </asp:UpdatePanel>
       </div>
    

    javascript:

        function C1TreeViewRows_NodeClicked(sender) {
            try {
                //alert('sener');
                var a = $find("<%=C1TreeViewRows.ClientID%>");
                var b = a.get_selectedNodes();
    
                var textbox = document.getElementById("<%= txtTreeRows.ClientID %>");
                var textbox2 = document.getElementById("<%= txtTreeRowsText.ClientID %>");
    
                if (b.length != 0) {
                    var c = b[0].get_value();
                    var t = b[0].get_text();
    
                    textbox.value = c;
                    textbox2.value = t;
                }
                else {
                    textbox.value = "";
                    textbox2.value = "";
                }
    
        function C1TreeView3_NodeClicked(sender) {
            var b = sender._treeViewNodes.list[0]._treeViewNodes;
            //var x = sender.get_checkedNodes();
            var x = sender.get_propertiesState();
            var c = b.list[1]._treeViewNodes.list[0];
            var textbox = document.getElementById("<%= txtTreeView3.ClientID %>");
            textbox.value = x;
        }
    
    
       
        function C1TreeViewColumns_OnClientNodeClicked(sender) {
            try {
                    var nodeSelected = sender.get_selectedNodes();
    
                    if (nodeSelected.length != 0) {
    
                        var value = nodeSelected[0].get_value();
                        var textbox = document.getElementById("<%= txtTreeCols.ClientID %>");
    
                        textbox.value = value;
    
    
                        var C1DateInput1 = Sys.Application.findComponent("<%= Text1.ClientID  %>");
                        var selectedDate = new Date(); //C1DateInput1.get_date();
                        switch (value) {
                            case 'TS1':
                                C1DateInput1.set_dateFormat('dd/MM/yyyy');
                                C1DateInput1.set_dateFormatResultPattern('dd/MM/yyyy');
                                C1DateInput1.set_date(selectedDate);
    
                                break;
                            case 'TS2':
                                C1DateInput1.set_dateFormat('MM/yyyy');
                                C1DateInput1.set_dateFormatResultPattern('MM/yyyy');
                                //selectedDate.setDate(1);
                                //C1DateInput1.set_date(selectedDate);
    
                                break;
                            case 'TS3':
                                C1DateInput1.set_dateFormat('yyyy');
                                C1DateInput1.set_dateFormatResultPattern('yyyy');
                                //selectedDate.setDate(1);
                                //selectedDate.setMonth(0);
                                //C1DateInput1.set_date(selectedDate);
    
                                break;
                            default:
    
    
                        }
                    }
                    else {
                        var textbox = document.getElementById("<%= txtTreeCols.ClientID %>");
    
                        textbox.value = "";
                    }
                //C1DateInput1.raisePropertyChanged('DateFormat');
               // C1DateInput1.initialize();
                
            }
            catch (e) {
                alert(e);
            }
        }

    any suggestions ?

  • Posted 11 May 2026, 9:10 am EST - Updated 12 May 2026, 3:11 am EST

    Properties ImageUrl and CollapsedImageUrl don’t exists.

    Legacy code:

       private void ClearTreeView(C1TreeView tree)
       {
           C1TreeViewNodeCollection nodes = tree.Nodes;
           foreach (C1TreeViewNode n in nodes)
           {
               n.Nodes.Clear();
           }
           nodes.Clear();
       }
    
        private void BuildTreeMainNodes(C1TreeView tree, string query)
        {
            C1TreeViewNode subNode;
    
            IGenericService service = new GenericService();
            DataTable dataTable = service.getDataTable(query);
    
            bool isSpecialBehaviour = GetConfigurationParameter(ConfigurationParamType.ConcessionCode) == "BR1" && IsCenter;
            foreach (DataRow dr in dataTable.Rows)
            {
                subNode = new C1TreeViewNode();
                subNode.Value = dr[0].ToString();
                subNode.Text = dr[1].ToString();
    
                if (tree.ID == "C1TreeViewRows")
                {
              
                }
    
                if (isSpecialBehaviour && (dr[0].Equals("GB5") || dr[0].Equals("GB4") || dr[0].ToString().Equals("5")))
                {
                    subNode.Enabled = false;
                }
                tree.Nodes.Add(subNode);
                IListNodesCount++;
            }
        }
    
        private void BuildTreeSubnodes(C1TreeViewNode node, string query)
        {
            if (node.Value == "PLT4")
            {
                node.Enabled = false;
            }
            C1TreeViewNode subNode;
            IGenericService service = new GenericService();
            DataTable dataTable = service.getDataTable(query);
    
            foreach (DataRow dr in dataTable.Rows)
            {
                subNode = new C1TreeViewNode();
                subNode.Value = dr[0].ToString();
                subNode.Text = dr[1].ToString();
                //subNode.ImageUrl = IListNodesCount.ToString();
                subNode.ImageUrl = "";
                subNode.CollapsedImageUrl = IListNodesCount.ToString();
                //subNode.ExpandedImageUrl = IListNodesCount.ToString();
    
                node.Nodes.Add(subNode);
                IListNodesCount++;
            }
        }

    More legacy code using CollapsedImageUrl , not exists now:

            private C1TreeViewNode FindNodeBreadthFirstSearch(C1TreeView tree, string value)
            {
                List<C1TreeViewNode> ListNode = new List<C1TreeViewNode>();
                ListNode.Add(tree.Nodes[0]);
                for (int i = 0; i < tree.Nodes.Count; i++)
                {
                    ListNode.Add(tree.Nodes[i]);
                }
                C1TreeViewNode node;
                while (ListNode.Count != 0)
                {
                    node = ListNode[0];
                    ListNode.RemoveAt(0);
                    //if (node.ImageUrl == value)
                    if (node.CollapsedImageUrl == value)
                    {
                        return node;
                    }
                    else
                    {
                        for (int i = node.Nodes.Count - 1; i >= 0; i--)
                        {
                            ListNode.Insert(0, node.Nodes[i]);
                        }
                    }
    
                }
                return null;
            }
  • Posted 12 May 2026, 5:21 am EST

    Hello Enrique,

    As per our understanding, the ImageUrl and CollapsedImageUrl properties used to get or set the path to an image to display for the node when it not expanded and expanded.

    In newer versions, the properties that matches this description are ItemIconClass and CollapsedIconClass

    Please refer to the following doc for more info: https://developer.mescius.com/componentone/docs/webforms/online-treeview/settingc1treeviewnod.html

    If these do not work, please share your use case for using these properties and we’ll try to provide best to implement it.

    Regards,

    Uttkarsh.

  • Posted 21 May 2026, 3:52 am EST

    Great !!

    using CollapsedIconClass like a “tag”, for assign a index for node

                foreach (DataRow dr in dataTable.Rows)
                {
                    subNode = new C1TreeViewNode();
                    subNode.Value = dr[0].ToString();
                    subNode.Text = dr[1].ToString();
    
                    // TODO: NEW 2025v2 No existe ImageUrl ni CollapsedImageUrl ni ExpandedImageUrl
                    subNode.ItemIconClass = "";
                    subNode.CollapsedIconClass = IListNodesCount.ToString();
    
                    // TODO : NEW 2025v2  ImageUrl CollapsedImageUrl no existe
                    //if (node.ImageUrl == value)
                    if (node.CollapsedIconClass == value)
                    {
                        return node;
                    }

    any suggestions Using CollapsedIconClass or another property?

  • Posted 21 May 2026, 6:00 am EST

    Hello Enrique,

    Regarding your question about using CollapsedIconClass as a node index tag — it should work, but it’s worth knowing that CollapsedIconClass is semantically meant to hold a CSS class name. Storing a numeric string there won’t break things immediately, but it could cause subtle rendering issues down the line (e.g. the control trying to apply your number as a CSS class on the node element), and it makes the intent of your code harder to understand for anyone maintaining it later.

    A cleaner approach is instead of tagging each node with an index via a property, maintain a server-side dictionary that maps each node’s Value → index, built at the same time you populate the tree.

    Call BuildNodeIndexMap() right after you finish populating the tree (i.e. at the end of your BuildTreeMainNodes / BuildTreeSubnodes calls, inside !IsPostBack).

    Then your FindNodeBreadthFirstSearch becomes much simpler — instead of checking node.CollapsedIconClass == value, you simply do a dictionary lookup.

    We have implemented the approach in the attached sample.

    Once you are done with migration, please evaluate and see if it works correctly as an alternative. (see TreeView_Sample.zip)

    For now, CollapsedIconClass should work without any issues. There are no alternatives for this other than implementing a dictionary to track node indexes as we suggested.

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels