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 / Client-side Events

Available actions
Logged events:







Event log:

  • RadTabStrip provides a number of client-side events that would allow you to accomplish even the most complicated tasks.

    You can attach to the RadTabStrip's events by using either the server-side properties or the client-side API.

    1. Attaching event handlers via a server-side property
      Each client-side event has a corresponding property, whose name is formed like OnClient[EventName].
      You can set the property to the name of the function to be called when the event occurs.
      <telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnClientTabSelected="onTabSelected"
      >
      </telerik:RadTabStrip>
      
      <script type="text/javascript" > function onTabSelected(sender, args) { alert("Selected: " + args.get_tab().get_text()); } </script>
    2. Using the client-side API to attach event handlers
      Using the client-side API of RadTabStrip allows you to attach multiple event handlers to one event using the standard MS AJAX conventions.
      <script type="text/javascript">
      	function onTabSelectedHandler1()
      	{
      		alert("First handler called");
      	}
      	function onTabSelectedHandler2()
      	{
      		alert("Second handler called");
      	}
      
      	function pageLoad()
      	{
      		var tabStrip = $find("<%=RadTabStrip1.ClientID%>");
      		
      		tabStrip.add_tabSelected(onTabSelectedHandler1);
      		tabStrip.add_tabSelected(onTabSelectedHandler2);
      	}
      </script>
      
      Another advantage of the client-side API is the possiblity of dynamically detaching certain handlers. You can use the remove_tabSelected method of the tabstrip object.

      <script type="text/javascript">
      	$find(<%=RadTabStrip1.ClientID%>).remove_tabSelected(onTabSelectedHandler1);
      </script>
      
    3. Cancelling an event
      The events, whose names end in ing, can be cancelled. You can cancel the event by using the set_cancel method of the event arguments passed to the handler.
      <script type="text/javascript">
      	function onClientTabSelecting(sender, eventArgs)
      	{
      	    eventArgs.set_cancel(true);
      	}
      </script>

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.ClientSide.ClientEvents.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>
    </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>

            <script type="text/javascript">
            //<![CDATA[
                
                function onTabSelecting(sender, args)
                {
                     logEvent("OnClientTabSelecting: " + args.get_tab().get_text());
                }
                
                function onTabSelected(sender, args)
                {
                     logEvent("OnClientTabSelected: " + args.get_tab().get_text());
                }
                
                function onMouseOver(sender, args)
                {
                     logEvent("OnClientMouseOver: " + args.get_tab().get_text());
                }
                
                function onMouseOut(sender, args)
                {
                     logEvent("OnClientMouseOut: " + args.get_tab().get_text());
                }
                
                function onLoad(sender, args)
                {
                     logEvent("OnClientLoad: " + sender.get_id());
                }
                
                function onContextMenu(sender, args)
                {
                    logEvent("OnClientContextMenu: " + args.get_tab().get_text());
                }
                
                function onDoubleClick(sender, args)
                {
                    logEvent("OnClientDoubleClick: " + args.get_tab().get_text());
                }
            //]]>
            </script>

            <div style="overflow:hidden;">
                <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Available actions" Orientation="Vertical" Expanded="true">
                    <div class="title">
                    Logged events:</div>
    <asp:CheckBox ID="OnClientLoad" runat="server" Text="OnClientLoad" AutoPostBack="True"
    Checked="True" OnCheckedChanged="OnClientLoad_CheckedChanged"></asp:CheckBox><br />

    <asp:CheckBox ID="OnClientTabSelecting" runat="server" Text="OnClientTabSelecting"
    AutoPostBack="True" Checked="True" OnCheckedChanged="OnClientTabSelecting_CheckedChanged">

                    </asp:CheckBox><br />
    <asp:CheckBox ID="OnClientTabSelected" runat="server" Text="OnClientTabSelected"
    AutoPostBack="True" Checked="True" OnCheckedChanged="OnClientTabSelected_CheckedChanged" />

                    <br />
    <asp:CheckBox ID="OnClientMouseOver" runat="server" Text="OnClientMouseOver" AutoPostBack="True"
    Checked="True" OnCheckedChanged="OnClientMouseOver_CheckedChanged" />

                    <br />
    <asp:CheckBox ID="OnClientMouseOut" runat="server" Text="OnClientMouseOut" AutoPostBack="True"
    Checked="True" OnCheckedChanged="OnClientMouseOut_CheckedChanged" />

                    <br />
    <asp:CheckBox ID="OnClientContextMenu" runat="server" Text="OnClientContextMenu"
    AutoPostBack="True" Checked="True" OnCheckedChanged="OnClientContextMenu_CheckedChanged" />

                    <br />
    <asp:CheckBox ID="OnClientDoubleClick" runat="server" Text="OnClientDoubleClick"
    AutoPostBack="True" Checked="True" OnCheckedChanged="OnClientDoubleClick_CheckedChanged" />

                    <br />
                </qsf:ConfiguratorPanel>
                <telerik:RadTabStrip runat="server" ID="RadTabStrip1" SelectedIndex="0" Style="float: left;"
                    OnClientTabSelecting="onTabSelecting" OnClientTabSelected="onTabSelected" OnClientLoad="onLoad"
                    OnClientMouseOver="onMouseOver" OnClientMouseOut="onMouseOut" OnClientContextMenu="onContextMenu"
                    OnClientDoubleClick="onDoubleClick">
                    <Tabs>
                        <telerik:RadTab runat="server" Selected="True" Text="Root RadTab1">
                            <Tabs>
                                <telerik:RadTab runat="server" Text="Child RadTab 1">
                                </telerik:RadTab>
                                <telerik:RadTab runat="server" Text="Child RadTab 2">
                                </telerik:RadTab>
                            </Tabs>
                        </telerik:RadTab>
                        <telerik:RadTab runat="server" Text="Root RadTab2">
                            <Tabs>
                                <telerik:RadTab runat="server" Text="Child RadTab 1">
                                </telerik:RadTab>
                                <telerik:RadTab runat="server" Text="Child RadTab 2">
                                </telerik:RadTab>
                            </Tabs>
                        </telerik:RadTab>
                        <telerik:RadTab runat="server" Text="Root RadTab3">
                            <Tabs>
                                <telerik:RadTab runat="server" Text="Child RadTab 1">
                                </telerik:RadTab>
                                <telerik:RadTab runat="server" Text="Child RadTab 2">
                                </telerik:RadTab>
                            </Tabs>
                        </telerik:RadTab>
                    </Tabs>
                </telerik:RadTabStrip>
            </div>
            <qsf:EventLogConsole ID="EventLogConsole1" runat="server" Style="clear: both;" />
            <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