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

PanelBar / Client-side Events

Available actions
Logged events:








Clear log Event log:

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

    You can attach to the RadPanelBar'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:RadPanelBar ID="RadPanelBar1" runat="server" OnClientItemClicking="onClicking" />
      
      <script type="text/javascript">
      	function onClicking(sender, eventArgs) 
      	{ 
      		var item = eventArgs.get_item();		
                      ...
      	} 
      </script>
      		
    2. Using the client-side API to attach event handlers
      Using the client-side API of RadPanelBar allows you to attach multiple event handlers to one event using the standard MS AJAX conventions.
      <script type="text/javascript">
      	function onClickingHandler1()
      	{
      		alert("First handler called");
      	}
      	function onClickingHandler2()
      	{
      		alert("Second handler called");
      	}
      
      	function pageLoad()
      	{
      		var panelBar = $find("<%=RadPanelBar1.ClientID%>");
      		
      		panelBar.add_itemClicking(onClickingHandler1);
      		panelBar.add_itemClicking(onClickingHandler2);
      	}
      </script>
      
      Another advantage of the client-side API is the possiblity of dynamically detaching certain handlers. You can use the remove_itemClicking method of the panelbar object.

      <script type="text/javascript">
      	$find(<%=RadPanelBar1.ClientID%>).remove_itemClicking(onClickedHandler1);
      </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 onClientItemClicking(sender, eventArgs)
      	{
      	    eventArgs.set_cancel(true);
      	}
      </script>

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="true" Inherits="Telerik.Web.Examples.PanelBar.ClientSide.ClientSideEvents.DefaultVB" %>
    <%@ 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" %>
    <!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 id="Headtag1" runat="server"></qsf:headtag>
        </head>
        <body class="BODY">
            <form id="mainForm" method="post" runat="server">
                <telerik:RadScriptManager ID="ScriptManager" runat="server" />
                <qsf:header id="Header1" runat="server" NavigationLanguage="VB"></qsf:header>
                <script type="text/javascript">
                    function OnMouseOver(sender, eventArgs)
                    {
                        logEvent("Mouse over: " + eventArgs.get_item().get_text());    
                    }
                    
                    function OnMouseOut(sender, eventArgs)
                    {
                        logEvent("Mouse out: " + eventArgs.get_item().get_text());    
                    }
                    
                    function OnClicking(sender, eventArgs)
                    {
                        logEvent("On clicking: " + eventArgs.get_item().get_text());                    
                    }
                                
                    function OnClicked(sender, eventArgs)
                    {
                        logEvent("On clicked: " + eventArgs.get_item().get_text());
                    }
                    
                    function OnExpand(sender, eventArgs)
                    {
                        logEvent("On expand: " + eventArgs.get_item().get_text());
                    }
                    
                    function OnCollapse(sender, eventArgs)
                    {
                        logEvent("On collapse: " + eventArgs.get_item().get_text());
                    }                
                    
                    function OnFocus(sender, eventArgs)
                    {
                        logEvent("On focus: " + eventArgs.get_item().get_text());
                    }
                    
                    function OnBlur(sender, eventArgs)
                    {
                        logEvent("On blur: " + eventArgs.get_item().get_text());
                    }                    
                </script>
                
                <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Available actions" Orientation="Vertical" Expanded="true">
                    Logged events:<br />
         <asp:CheckBox ID="MouseOut" Runat="server" Text="OnClientMouseOut" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="MouseOver" Runat="server" Text="OnClientMouseOver" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemClicking" Runat="server" Text="OnClientItemClicking" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemClicked" Runat="server" Text="OnClientItemClicked" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemOpen" Runat="server" Text="OnClientItemExpand" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemClose" Runat="server" Text="OnClientItemCollapse" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemFocus" Runat="server" Text="OnClientItemFocus" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
         <asp:CheckBox ID="ItemBlur" Runat="server" Text="OnClientItemBlur" AutoPostBack="True" Checked="True"></asp:CheckBox><br />
             </qsf:ConfiguratorPanel>
            
                <telerik:RadPanelBar runat="server" ID="RadPanelBar1" Height="336px" ExpandMode="FullExpandedItem">
                    <Items>
                        <telerik:RadPanelItem Expanded="True" Text="ASP.NET controls">
                            <Items>
                                <telerik:RadPanelItem Text="RadMenu"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadTabStrip"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadPanelBar"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadTreeView"></telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="WinForms controls">
                            <Items>
                                <telerik:RadPanelItem Text="RadMenustrip"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadTabStrip"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadToolStrip"></telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                        <telerik:RadPanelItem Text="Other projects">
                            <Items>
                                <telerik:RadPanelItem Text="SiteFinity"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="Reporting"></telerik:RadPanelItem>
                                <telerik:RadPanelItem Text="RadAjax"></telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelBar>
                
                <qsf:EventLogConsole ID="EventLogConsole1" runat="server" AllowClear="true" />

                <qsf:footer id="Footer1" runat="server"></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