[CLOSED] Dynamically adding controls to a tav

  1. #1

    [CLOSED] Dynamically adding controls to a tav

    I tried to build a TabPanel dynamically: adding Tabs to TabPanel and Buttons to each tabs. In the follow I list a very simple example. Issues come as Buttons doesn't show up properly. They come on top of the TabPanel instead of being shown inside of each appropiate Tab.
    In the example each Tab is added with a Panel which is suposed to hold the Buttons. I also tried to add Button to either the Tab.Items or Tab.Control collection directly but nothing happens

    can anyone help please?

    
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
    Coolite.Ext.Web.TabPanel tabs = new Coolite.Ext.Web.TabPanel();
    tabs.ResizeTabs = true;
    tabs.MinTabWidth = Unit.Pixel(115);
    tabs.TabWidth = Unit.Pixel(135);
    tabs.EnableTabScroll = true;
    tabs.Width = Unit.Pixel(600);
    tabs.Height = Unit.Pixel(300);
    tabs.ActiveTab = 0;
    tabs.BodyBorder = false;
    tabs.Border = true;
    for (int i = 1; i<4; i++)
    {
    Tab tab = new Tab();
    tab.Title = "world " + i.ToString();
    tab.IconCls = "tabs";
    tab.Closable = false;
    tab.BodyStyle = "padding: 6px;";
    tab.Frame = false;
    Coolite.Ext.Web.Panel p = new Coolite.Ext.Web.Panel();
    for (int j = 0; j < i; j++)
    {
    Coolite.Ext.Web.Button btn = new Coolite.Ext.Web.Button();
    btn.Text = "type " + i.ToString() + "_" + j.ToString();
    btn.ToolTip = "description for type " + i.ToString() + "_" + j.ToString();
    btn.Visible = true;
    p.Controls.Add(btn);
    }
    tab.Items.Add(p);
    tabs.Tabs.Add(tab);
    }
    this.PlaceHolder1.Controls.Add(tabs);
    }
  2. #2

    RE: [CLOSED] Dynamically adding controls to a tav



    I took a quick look at your code sample and I think you just need to add the Button(s) to the Panel's .ContentControls collection instead of the .Controls collection.

    Example

    // Old
    p.Controls.Add(btn);
    
    
    // New
    p.ContentControls.Add(btn);
    Hope this helps. Let us know if this solves the problem.
    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Dynamically adding controls to a tav



    I think the Panel needs to be added to Tab's .ContentControls collection as well.

    Example

    tab.ContentControls.Add(p);
    Geoffrey McGill
    Founder
  4. #4

    RE: [CLOSED] Dynamically adding controls to a tav

    OK thx all, also found this topic had already been discussed. Sorry for the post

Similar Threads

  1. [CLOSED] Adding portlets dynamically
    By GmServizi in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Aug 31, 2012, 7:14 PM
  2. Dynamically adding Controls to WebUserControl
    By bright in forum 1.x Help
    Replies: 8
    Last Post: Apr 27, 2012, 6:34 PM
  3. Replies: 2
    Last Post: Dec 15, 2011, 11:58 AM
  4. Replies: 1
    Last Post: Aug 17, 2010, 10:07 PM
  5. Replies: 2
    Last Post: Nov 04, 2009, 3:36 PM

Posting Permissions