EXT.NET 3.0.0 RELEASED!
Now with Tablet Support!
Ext.NET 3.0.0 is here with lots of new cool features and now with tablet support! Check Examples Explorer now to see it in action or download and test it yourself for free!
Results 1 to 2 of 2

Thread: treepanel in CodeBehind on button click ?

  1. #1
    Member
    Join Date
    Oct 2010
    Posts
    5

    treepanel in CodeBehind on button click ?

    Code:
    <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 1:58 PM. Reason: Please use [CODE] tags

  2. #2
    Ext.NET - Support Team Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    28,076
    Hi,

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

    Please use .AddTo() to render.
    Code:
    tree.AddTo(someContainer);
    Daniil
    Ext.NET, Inc.
    Support Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

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, 5:23 PM
  2. Replies: 4
    Last Post: Nov 19, 2010, 2:39 PM
  3. Replies: 3
    Last Post: Sep 20, 2010, 10:52 AM
  4. Replies: 2
    Last Post: Oct 30, 2009, 2:54 PM
  5. TreePanel can not show in codebehind
    By bluebirdzx in forum 1.x Help
    Replies: 2
    Last Post: Apr 21, 2009, 12:37 AM

Posting Permissions