[CLOSED] Unable to render controls within dynamically created TabPanel

  1. #1

    [CLOSED] Unable to render controls within dynamically created TabPanel

    Hi,

    I am trying to add buttons within TabPanel's tab . My TabPanel is dynamic.
    With my code, its rendering on top of TabPanel


    Please help. My aim is to render a set of controls in tabular format.
    Any help will be greatly appreciated.

    //====================
    //Markup Of My Page
    //====================

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DynamicTabDemo.aspx.cs" Inherits="DynamicControlPopulateDemo.DynamicTabDemo" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
        <body>
            <form id="form1" runat="server">
                
                    <ext:ScriptManager ID="ScriptManager1" runat="server" />
                    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                
    
            </form>
        </body>
    </html>
    //====================
    //==Code Behind
    //====================

     protected void Page_InIt(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.LayoutOnTabChange = true;
        tabs.ActiveTabIndex = 1;
        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);
                //p.Items.Add(btn);
            }
            tab.Items.Add(p);
            tabs.Tabs.Add(tab);
       }// Add Window to Form
     this.PlaceHolder1.Controls.Add(tabs);
    
    
    }
    Last edited by geoffrey.mcgill; Feb 20, 2015 at 2:39 PM.
  2. #2

    RE: [CLOSED] Unable to render controls within dynamically created TabPanel

    Hi,

    1. Instead Controls use BodyControls
    p.BodyControls.Add(btn);
    2. Instead Items use BodyControls
    tab.BodyControls.Add(p);

    Here is modified Page_Init
    protected void Page_InIt(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.LayoutOnTabChange = true;
                tabs.ActiveTabIndex = 1;
                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.BodyControls.Add(btn);
                        //p.Items.Add(btn);
                    }
                    tab.BodyControls.Add(p);
                    tabs.Tabs.Add(tab);
                }// Add Window to Form
                this.PlaceHolder1.Controls.Add(tabs);
    
            }
  3. #3

    RE: [CLOSED] Unable to render controls within dynamically created TabPanel

    Thanks

    It worked

Similar Threads

  1. saving dynamically-created controls' values
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2012, 12:54 PM
  2. [CLOSED] How to clean up dynamically created controls?
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 23, 2011, 9:51 AM
  3. [CLOSED] Unable to access dynamically created controls
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 07, 2011, 5:49 AM
  4. Replies: 6
    Last Post: Jun 18, 2010, 4:23 PM
  5. Dynamically created controls cookbooks
    By arodier in forum 1.x Help
    Replies: 15
    Last Post: May 07, 2010, 7:12 PM

Posting Permissions