Select a tab server side or client side and fire the tabclick event.

3 posts, 1 answers
  1. Julie
    Julie avatar
    27 posts
    Member since:
    Dec 2008

    Posted 07 Apr 2009 Link to this post

    Hi Telerik Support,
    I am working with the tabstrip, is there a way to programatically force the tabclick event?

    I need to programatically select a tab server side.. any suggestions would be appreciated.
    Thanks
    ~Julie
  2. Answer
    Paul
    Admin
    Paul avatar
    4281 posts

    Posted 08 Apr 2009 Link to this post

    Hello Julie,

    Here's a sample code snippe that shows the needed approach.

    ASPX:
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
     
    <script type="text/javascript">  
    function selectTab() {  
        var tabstrip = $find('<%= RadTabStrip1.ClientID %>');  
        tabstrip.findTabByText("Root RadTab3").click();  
    }  
    </script> 
     
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnTabClick="RadTabStrip1_TabClick">  
    <Tabs> 
        <telerik:RadTab runat="server" Text="Root RadTab1">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Root RadTab2">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Root RadTab3">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Root RadTab4">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Root RadTab5">  
        </telerik:RadTab> 
        <telerik:RadTab runat="server" Text="Root RadTab6">  
        </telerik:RadTab> 
    </Tabs> 
    </telerik:RadTabStrip> 
    <input id="Button2" type="button" value="Select Tab3" onclick="selectTab()" /> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    </form> 

    Code-behind:
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using Telerik.Web.UI;  
     
    public partial class _Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
                     
        }  
     
        protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)  
        {  
            Label1.Text = e.Tab.Text;  
        }  
    }  
     


    Regards,
    Paul
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Julie
    Julie avatar
    27 posts
    Member since:
    Dec 2008

    Posted 08 Apr 2009 Link to this post

    Perfect!!!
    Thanks for the help!
    ~Julie
Back to Top