PDA

View Full Version : [CLOSED] Tabpanel in tabpanel from code behind



Jurke
Oct 29, 2008, 6:23 AM
Hi
I want to have a tabpanel with tabs, and in each tab I want to add another tabpanel that also contains tabs, I want to to this from the code behind and I cat get it to work. Please have a look at the sample code.







<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<ext:ScriptManager ID="ScriptManager2" runat="server" HideInDesign="false">
</ext:ScriptManager>
<ext:TabPanel Plain="true" ID="TabPanelOuter" AutoWidth="true" AutoHeight="true" BodyBorder="true" Border="true" runat="server" >
</ext:TabPanel>
</form>
</body>
</html>




public partial class Test_Default : System.Web.UI.Page
{</p>


</p>


protected void Page_Load(object sender, EventArgs e)
{</p>


    for (int i = 0; i < 2; i++)
    {</p>


        Tab tabOuter = new Tab("tabOuter" + i, "TabOuter "+i);</p>


        TabPanelOuter.Tabs.Add(tabOuter);</p>


</p>


        TabPanel TabPanelInner = new TabPanel();</p>


        TabPanelInner.ID = "TabPanelInner" + i;</p>


        TabPanelInner.Plain = true;</p>


        tabOuter.Controls.Add(TabPanelInner);for (int j = 0; j < 2; j++)
        {
            Tab tabInner = new Tab();
            tabInner.ID = "tabInner" +i.ToString() +"_"+ j.ToString();
            tabInner.Title = "TabInner" + i;
            tabInner.Html = "Test";
            TabPanelInner.Tabs.Add(tabInner);
        }
    }
}
}


Best regards
Mikael Jürke</p>

Vladimir
Oct 29, 2008, 8:29 AM
Hi Mikael,

Please, see my example


<%@ Page Language="C#" %>

<%@ 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">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 2; i++)
{
Tab tabOuter = new Tab("tabOuter" + i, "TabOuter " + i);
TabPanelOuter.Tabs.Add(tabOuter);
FitLayout fitLayout = new FitLayout();
tabOuter.BodyControls.Add(fitLayout);

TabPanel TabPanelInner = new TabPanel();
TabPanelInner.ID = "TabPanelInner" + i;
TabPanelInner.Plain = true;
fitLayout.Items.Add(TabPanelInner);

for (int j = 0; j < 2; j++)
{
Tab tabInner = new Tab();
tabInner.ID = "tabInner" + i.ToString() + "_" + j.ToString();
tabInner.Title = "TabInner" + i;
tabInner.Html = "Test";
TabPanelInner.Tabs.Add(tabInner);
}
}
}
</script>

<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" StateProvider="None" ScriptMode="Debug" />

<ext:TabPanel ID="TabPanelOuter" runat="server"
Plain="true"
AutoWidth="true"
Height="300"
BodyBorder="true"
Border="true">
</ext:TabPanel>
</form>
</body>
</html>

Jurke
Oct 29, 2008, 8:56 AM
Hi
Thank you very much! Works perfectly.



/Mikael