Wednesday, March 28, 2012

Dynamic ContentTemplate in the TabPanel

How can i create a dynamic ContentTemplate in the TabPanel control ?

I have the following source:

<asp:ScriptManager ID="scriptManMain" runat="server" EnablePartialRendering="true" />
<ajaxToolkit:TabContainer runat="server" ID="tabContainerMS" CssClass="ajax__tab_xp">
<ajaxToolkit:TabPanel runat="Server" ID="tabPanelMaster" HeaderText="Orders Due Today">
<ContentTemplate>
XXXXXXXXX
<ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>

I wanna change the ContentTemplate dynamic by a file .cs on page_load or another function, how can i do that ?

Thank′s

You could use the dynamic population capabilities of the tabpanel control for this which allows you to populate the content of each tab when it is activated via a web service call. Check out the Dynamic* properties on the control.
AjaxControlToolkit.TabPanel tpHome = new AjaxControlToolkit.TabPanel();
tpHome.HeaderText = "Home";
tpHome.ContentTemplate = Page.LoadTemplate("Home.ascx");
tcDefault.Tabs.Add(tpHome);

where tcDefault is TabControl you want this tabPanel to add, so Page.LoadTemplate is the method you should use

No comments:

Post a Comment