The tabstrip in conjunction with the multipage can be used to load dynamic UserControls.
The example above demonstrates dynamic creation of tabs, pageviews and loading UserControls
inside the pageviews. Notice the usage of the PageViewCreated
event to persist the dynamically created controls inside a RadPageView.
In addition, we have to explicitly set IDs to the UserControls.
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
AddTab("Corporate");
AddTab("Personal");
}
}
private void AddTab(string tabName)
{
RadTab tab = new RadTab();
tab.Text = tabName;
RadTabStrip1.Tabs.Add(tab);
RadPageView pageView = new RadPageView();
pageView.ID = tabName;
RadMultiPage1.PageViews.Add(pageView);
}
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
string userControlName = e.PageView.ID + "CS.ascx";
Control userControl = Page.LoadControl(userControlName);
userControl.ID = e.PageView.ID + "_userControl";
e.PageView.Controls.Add(userControl);
}