The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

treepanel in CodeBehind on button click ?

  1. #1

    treepanel in CodeBehind on button click ?

    <ext:Button runat="server" ID = "btnLoad" Text="开始菜单">
            <DirectEvents>
                <Click OnEvent="btnLoad_Click"></Click>
            </DirectEvents>
        </ext:Button>
        <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
    
     protected void btnLoad_Click(object sender, DirectEventArgs e)
        {        
            Ext.Net.TreePanel tree = new Ext.Net.TreePanel();        
            tree.ID = "TreePanel1";
            tree.Width = Unit.Pixel(300);
            tree.Height = Unit.Pixel(450);
            tree.Icon = Icon.BookOpen;
            tree.Title = "Catalog";
            tree.AutoScroll = true;
            this.PlaceHolder1.Controls.Add(tree);
            Ext.Net.Button btnExpand = new Ext.Net.Button();
            btnExpand.Text = "Expand All";
            btnExpand.Listeners.Click.Handler = tree.ClientID + ".expandAll();";
    
            Ext.Net.Button btnCollapse = new Ext.Net.Button();
            btnCollapse.Text = "Collapse All";
            btnCollapse.Listeners.Click.Handler = tree.ClientID + ".collapseAll();";
    
            Toolbar toolBar = new Toolbar();
            toolBar.ID = "Toolbar1";
            toolBar.Items.Add(btnExpand);
            toolBar.Items.Add(btnCollapse);
            tree.TopBar.Add(toolBar);
    
            StatusBar statusBar = new StatusBar();
            statusBar.AutoClear = 1000;
            tree.BottomBar.Add(statusBar);
    
            tree.Listeners.Click.Handler = statusBar.ClientID + ".setStatus({text: 'Node Selected: <b>' + node.text + '</b>', clear: true});";
            tree.Listeners.ExpandNode.Handler = statusBar.ClientID + ".setStatus({text: 'Node Expanded: <b>' + node.text + '</b>', clear: true});";
            tree.Listeners.ExpandNode.Delay = 30;
            tree.Listeners.CollapseNode.Handler = statusBar.ClientID + ".setStatus({text: 'Node Collapsed: <b>' + node.text + '</b>', clear: true});";
    
            Ext.Net.TreeNode root = new Ext.Net.TreeNode("Composers");
            root.Expanded = true;
            tree.Root.Add(root);
    }

    why treepanel no load?
    Last edited by Daniil; Apr 13, 2011 at 12:58 PM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    I see where you create the tree, but can't see where you render it.

    Please use .AddTo() to render.
    tree.AddTo(someContainer);
    Daniil Veriga
    Developer & Support Expert

Similar Threads

  1. [CLOSED] When button click, open the menu of button
    By supera in forum 2.x Premium Help
    Replies: 2
    Last Post: Feb 22, 2012, 4:23 PM
  2. Replies: 4
    Last Post: Nov 19, 2010, 1:39 PM
  3. Replies: 3
    Last Post: Sep 20, 2010, 9:52 AM
  4. Replies: 2
    Last Post: Oct 30, 2009, 1:54 PM
  5. TreePanel can not show in codebehind
    By bluebirdzx in forum 1.x Help
    Replies: 2
    Last Post: Apr 20, 2009, 11:37 PM

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.