Set RadTabStrip.MultiPageId to MultiPage on MasterPage

2 posts, 1 answers
  1. Thad
    Thad avatar
    106 posts
    Member since:
    Sep 2010

    Posted 17 Feb 2012 Link to this post

    Hello,

    Can I have a RadTabStrip inside of a ContentPlaceHolder that loads content into a RadMultiPage control that sits on the MasterPage?  Setting the radTabStrip.MultiPageID to either the ID or ClientID of the RadMultiPage still leaves radTab.MultiPage set to null so PageViews can not be added dynamically.

    More details:
    Our master page has a content place holder for tabs and we want to be able to have the RadMultiPage control on the MasterPage so that it can be shared by the half dozen user controls with RadTabStrip controls.  Also, we want to decouple the two controls so that the content loaded into the MultiPage can be positioned in the page flow wherever the designers feel it should sit.

    Piece of master page:
    <!-- holds the page banner -->
    <asp:Panel runat="server" ID="pnlBanner">
        <asp:ContentPlaceHolder ID="cphBannerContent" runat="server" />
    </asp:Panel>
    <!-- holds the tabstrip appropriate for the appropriate page -->
    <asp:Panel runat="server" ID="pnlTabs">
        <asp:ContentPlaceHolder ID="cphTabsContent" runat="server" />
    </asp:Panel>
    <div class="contentWidth">
        <!-- Content placed at the beginning of the page prior to any regular content-->
        <asp:Panel runat="server" ID="pnlPageHeader">
            <asp:ContentPlaceHolder ID="cphPageHeaderContent" runat="server" />
        </asp:Panel>
        <div>
            <telerik:RadMultiPage ID="rmpMain" runat="server" SelectedIndex="0" />
        </div>
        <!-- Master page automatically ajaxifies any content placed here -->
        <asp:Panel runat="server" ID="pnlAutoAjaxified">
            <asp:ContentPlaceHolder ID="cphAutoAjaxifiedContent" runat="server" />
        </asp:Panel>
        <!-- Any content placed here must be ajaxified by the page -->
        <asp:Panel runat="server" ID="pnlSelfAjaxified">
            <asp:ContentPlaceHolder ID="cphSelfAjaxifiedContent" runat="server" />
        </asp:Panel>
    </div>

    On our page we have a RadTabStrip inside of the content placeholder "cphTabsContent" and dynamically load UserControls into each tab when clicked using code derived from the demo program.
    Here is the RadTabStrip on the demo page:
    <telerik:RadTabStrip ID="rtsDemo" runat="server" AutoPostBack="true" CausesValidation="false"
        Orientation="HorizontalTop" SelectedIndex="0">
        <Tabs>
            <telerik:RadTab NavigateUrl="" Text="Tab 1" ToolTip="Tab 1" Value="Tab1" />
            <telerik:RadTab NavigateUrl="" Text="Tab 2" ToolTip="Tab 2" Value="Tab2" />
            <telerik:RadTab NavigateUrl="" Text="Tab 3" ToolTip="Tab 3" Value="Tab3" />
            <telerik:RadTab NavigateUrl="" Text="Tab 4" ToolTip="Tab 4" Value="Tab4" />
        </Tabs>
    </telerik:RadTabStrip>

    In the OnInit event I'm trying to set the MultiPageID of the RadTabStrip to the one on the MasterPage, but no matter what I do it doesn't work.
    rtsDemo.MultiPageID = "rtsMain"; // didn't work
    rtsDemo.MultiPageID = "ctl100_rtsMain"; // didn't work

    When we click on a tab, here is the code that runs:
    private void TabStrip_TabClick(object sender, RadTabStripEventArgs e)
    {
        AddPageView(e.Tab);
        SelectTab(e.Tab);
    }
     
    private void AddPageView(RadTab radTab)
    {
        RadPageView pageView = new RadPageView {ID = radTab.Value, Selected = true};
        // If the PageView is already added to the RadMultiPage, then don't add it again
        if (MasterMultiPage.PageViews.Cast<RadPageView>().Any(multiPage => multiPage.ID == radTab.Value))
        {
            radTab.PageViewID = pageView.ID;
            radTab.PageView.Selected = true;
            return;
        }
        // Add a new PageView to the RadMultiPage
        MasterMultiPage.PageViews.Add(pageView);
        radTab.PageViewID = pageView.ID;
        radTab.PageView.Selected = true;// ERROR!!  radTab.PageView is always NULL
    }
     
    private static void SelectTab(RadTab tab, bool withParent = true)
    {
        // Select tab
        tab.Selected = true;
     
        // Determine if tab has tab
        if (withParent && tab.Parent is RadTab)
        {
            tab.SelectParents();
        }
    }
  2. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 22 Feb 2012 Link to this post

    Hi Thad,

    In order to use RadTabStrip and RadMultiPage they both should be in one and the same NamingContainer. This is the cause of your issue, since in your case the controls are in different NamingContainer.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top