Show/Hide tabs

2 posts, 0 answers
  1. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 16 Dec 2011 Link to this post


    Can somebody help me with showing and hiding tabs in code behind? I've tried many methods and none seem to work. I really appreciate your assistance with this one.

  2. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 16 Dec 2011 Link to this post


    Here's a basic sample that employs "RadTabStrip.FindTabByText(TextBox1.Text)" with the "Tab.Visible = true" properties to show/hide the RadTabStrip tabs in the code behind of a C# sample.

    "Default.aspx" Source Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        <script type="text/javascript">
            //Put your JavaScript code here.
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <div style="background: url(Img/bg.gif) no-repeat; width: 600px; height: 362px; padding-top: 24px;
            text-align: left;">
            <asp:Label ID="Label1" runat="server" Text="Enter a Tab Name"></asp:Label>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <asp:Button Text="Hide Root Tab" OnClick="hideRootTab_Click" runat="server" ID="hideRootTab"
                Style="width: 116px;"></asp:Button>
            <asp:Button Text="Show Root Tab" OnClick="showRootTab_Click" runat="server" ID="showRootTab"
            <asp:Button Text="Hide Child Tab" OnClick="hideChildTab_Click" runat="server" ID="hideChildTab"
                Style="width: 116px;"></asp:Button>
            <asp:Button Text="Show Child Tab" OnClick="showChildTab_Click" runat="server" ID="showChildTab"
        <br />
            <telerik:RadTabStrip ID="RadTabStrip1" runat="server">
    "Default.aspx.cs" code behind:
    using System;
    using Telerik.Web.UI;
    public partial class Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                for (int i = 0; i < 4; i++)
                    RadTab rootTab = new RadTab();
                    rootTab.Text = "Root Tab " + RadTabStrip1.Tabs.Count;
                    rootTab.Value = i.ToString();
                    for (int j = 0; j < 4; j++)
                        RadTab childTab = new RadTab();
                        childTab.Text = string.Format("Child Tab {0}.{1}", i + 1, rootTab.Tabs.Count);
                RadTabStrip1.SelectedIndex = 0;
        protected void hideRootTab_Click(object sender, EventArgs e)
            RadTab rootTab = RadTabStrip1.FindTabByText(TextBox1.Text);
            rootTab.Visible = false;
        protected void showRootTab_Click(object sender, EventArgs e)
            RadTab rootTab = RadTabStrip1.FindTabByText(TextBox1.Text);
            rootTab.Visible = true;
        protected void hideChildTab_Click(object sender, EventArgs e)
            RadTab childTab = RadTabStrip1.FindTabByText(TextBox1.Text);
            childTab.Visible = false;
        protected void showChildTab_Click(object sender, EventArgs e)
            RadTab childTab = RadTabStrip1.FindTabByText(TextBox1.Text);
            childTab.Visible = true;

    Hope this helps.

Back to Top