Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

TabStrip / Dynamic RadPageView

Company:
Address:
Web-site:
Activities:

Name:
Surname:
Birthday:
Interests:


  • 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);
    }
    

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="false" Inherits="Telerik.Web.Examples.TabStrip.ApplicationScenarios.DynamicPageView.DefaultVB" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
        <style type="text/css">
            #exampleBg
            {
                background: url(Img/bg.gif) no-repeat;
                width: 395px;
                height: 339px;
                padding-top:61px;
                padding-left: 27px;
                position:relative;
                margin: 20px auto 0 auto;
            }

            .tableLabels
            {
                font-size: 12px;
                color: #666666;
                margin-left:11px;
                
            }
            .exButton
            {
                margin-top: 11px;
                margin-left: 75px;
                background: url(Img/button.gif) no-repeat;
                width: 122px;
                height: 33px;
                border: 0;
                color: #cc0066;
                font-size: 11px;
                text-align:left;
                padding-left:25px;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
            <telerik:RadScriptManager ID="ScriptManager" runat="server" />
            <qsf:Header runat="server" ID="Header1" NavigationLanguage="VB"></qsf:Header>
            <div id="exampleBg">
                <telerik:RadTabStrip Style="position: absolute; top: 84px;" ID="RadTabStrip1" SelectedIndex="0"
                    runat="server" MultiPageID="RadMultiPage1">
                </telerik:RadTabStrip>
                <telerik:RadMultiPage Style="position: absolute; top: 134px;" ID="RadMultiPage1"
                    runat="server" SelectedIndex="0">
                </telerik:RadMultiPage>
            </div>
            <qsf:Footer runat="server" ID="Footer1"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451