c# - Adding aTabPanel dynamically and making its ContentTemplate from ASPX -
context:
an ajax control toolkit tabcontainer, each tabpanel generated code behind, , contenttemplate custom control.
the custom control corresponds goes directly in tabpanel's contenttemplate:
<%@ control language="c#" autoeventwireup="true" codebehind="tabcontenttemplatetest.ascx.cs" inherits="webgui.controls.tabcontenttemplatetest" %> <asp:label runat="server" id="tabtext" /> and code behind:
public partial class tabcontenttemplatetest : usercontrol, itemplate { public string number { get; set; } protected void page_load(object sender, eventargs e) { tabtext.text = number; } public void instantiatein(control container) { container.controls.add(this); } } creation (code behind of tabcontainertest, having tabcontainer named samplestabcontainer):
public string[] numbers = { "zero", "one", "two", "three", "four" }; protected void page_load(object sender, eventargs e) { (int = 0; < 5; i++) { var tabcontent = loadcontrol("~/controls/tabcontenttemplatetest.ascx") tabcontenttemplatetest; tabcontent.number = numbers[i]; samplestabcontainer.tabs.add(new tabpanel { headertext = i.tostring(), contenttemplate = tabcontent }); } } the problem content (here simplified label) doesn't show.
how can generate custom control aspx contenttemplate , display it?
setting tabpanel's ondemandmode ondemandmode.none forces addition of controls right away, makes them display.
Comments
Post a Comment