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

ComboBox / Client-side Events

Logged events
Clear log Event log:

  • RadComboBox provides a rich set of client-side events. Here's a list of all client-side events exposed by the combobox:

    • OnClientSelectedIndexChanging
    • OnClientSelectedIndexChanged
    • OnClientDropDownClosing
    • OnClientDropDownOpening
    • OnClientItemsRequested
    • OnClientItemsRequesting
    • OnClientItemBlur
    • OnClientItemBlur
    • OnClientFocus
    • OnClientKeyPressing
    • OnClientCallBackError

    The client-side events are directly assigned to the combobox control as for an example:

        <telerik:radcombobox
    
    ...
    OnClientSelectedIndexChanged = "OnClientSelectedIndexChangedEventHandler" />
    All client side events take two parameters - sender and arguments:
            function OnClientSelectedIndexChangedEventHandler(sender, args) 
    
            {
              //sender represents the combobox that has fired the event             //the code below obtains the item that has been changed             var item = args.get_item();
    }

    All events that end in "ing" (i.e. OnClientSelectedIndexChanging)" can be cancelled. To do this you should call the set_cancel(true) method in the event handler:

             function HandleStartChanging(sender, args)
    
           {                           set_cancel(true);                        }

    Once, the OnClientSelectedIndexChanging event is cancelled, no other items can be selected.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.ComboboxExamplesVB.ClientEvents.DefaultVB"
        Language="vb" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ 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 id="Head1" runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        
        <link rel="stylesheet" type="text/css" href="styles.css" />
    </head>
    <body class="BODY">
        <form id="mainForm" method="post" runat="server">
            <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" />
            
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
            
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Logged events" Expanded="true">
                    <ul style="margin-left: 0; border-left: none">
                        <li>
    <asp:CheckBox ID="DropDownOpening" runat="server" Text="OnClientDropDownOpening"
    AutoPostBack="True" Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="DropDownOpened" runat="server" Text="OnClientDropDownOpened" AutoPostBack="True"
    Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="DropDownClosing" runat="server" Text="OnClientDropDownClosing"
    AutoPostBack="True" Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="DropDownClosed" runat="server" Text="OnClientDropDownClosed" AutoPostBack="True"
    Checked="True" />

                        </li>
                    </ul>
                    <ul>
                        <li>
    <asp:CheckBox ID="SelectedIndexChanging" runat="server" Text="OnClientSelectedIndexChanging"
    AutoPostBack="True" Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="SelectedIndexChanged" runat="server" Text="OnClientSelectedIndexChanged"
    AutoPostBack="True" Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="ItemsRequesting" runat="server" Text="OnClientItemsRequesting"
    AutoPostBack="True" Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="ItemsRequested" runat="server" Text="OnClientItemsRequested" AutoPostBack="True"
    Checked="True" />

                        </li>
                    </ul>
                    <ul>
                        <li>
    <asp:CheckBox ID="KeyPressing" runat="server" Text="OnClientKeyPressing" AutoPostBack="True"
    Checked="True" />

                        </li>
                        <li>
    <asp:CheckBox ID="TextChange" runat="server" Text="OnClientTextChange" AutoPostBack="True"
    Checked="True" />

                        </li>
                    </ul>
                </qsf:ConfiguratorPanel>
                
                <telerik:RadComboBox
                    ID="RadComboBox1" runat="server"
                    Height="170px" Width="204px"
                    ShowMoreResultsBox="True"
                    EnableLoadOnDemand="True"
                    OnItemsRequested="RadComboBox1_ItemsRequested"
                    style="margin: 20px auto; display:block !important;" />

            </telerik:RadAjaxPanel>
            
            <qsf:EventLogConsole ID="EventLogConsole1" runat="server" AllowClear="true" />

            <script type="text/javascript">
                function onDropDownOpening(sender)
                {
                    logEvent("Drop Down opening");
                }

                function onDropDownOpened(sender)
                {
                    logEvent("Drop Down opened");
                }

                function onDropDownClosing(sender)
                {
                    logEvent("Drop Down closing");
                }

                function onDropDownClosed(sender)
                {
                    logEvent("Drop Down closed");
                }

                function onSelectedIndexChanging(sender, eventArgs)
                {
                 var item = eventArgs.get_item();
                
                    var selectedItem = sender.get_selectedItem();
                    var previouslySelectedItemText = selectedItem != null ? selectedItem.get_text() : sender.get_text();
                    
                    logEvent("Changing from Item '" + previouslySelectedItemText + "'");
                }

                function onSelectedIndexChanged(sender, eventArgs)
                {
                    var selectedItem = eventArgs.get_item();
                    var selectedItemText = selectedItem != null ? selectedItem.get_text() : sender.get_text();
                    
                    logEvent("Changed to Item '" + selectedItemText + "'");
                }

                function onItemsRequesting(sender, eventArgs)
                {
                    logEvent("Requesting Items with text '"+ eventArgs.get_text()+"'");
                }
                
                function onItemsRequested(sender, eventArgs)
                {
                    logEvent("Items requested with text '"+ eventArgs.get_text()+"'");
                }

                function onKeyPressing(sender, eventArgs)
                {
                    logEvent("Pressed key code: "+ eventArgs.get_domEvent().keyCode);
                }

                function onTextChange(sender)
                {
                    logEvent("Text changed to: "+ sender.get_text());
                }
            </script>
            
            <qsf:Footer runat="server" ID="Footer1" />
        </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