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

Button / Split Button

  • Argentina
  • Australia
  • Brazil
  • Canada
  • Chile
  • China
  • Egypt
  • England

  • Use a split button to consolidate a set of variations of a command, especially when one of the commands is used most of the time.
    The SplitButton control in this demo supports the following behaviors:

    • When clicked for a first time the splitbutton will expand a hidden dropdown under it with a list of available options.
    • If an item in the dropdown is pressed, the split button header will be updated with the selected command name and it will be executed.
    • To apply the lastly selected command, just click the button's header, instead of expanding the dropdown again.
    • To apply another command just click on the splitbutton arrow, and choose the desired command from the expanded dropdown.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" AutoEventWireup="true" %>

    <%@ 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 runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" />
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" />
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <div style="width: 450px; margin-left: 90px;">
                <telerik:RadListBox ID="RadListBoxSource" runat="server" Height="200px" TransferToID="RadListBoxDestination">
                    <Items>
                        <telerik:RadListBoxItem Text="Argentina" Selected="true" />
                        <telerik:RadListBoxItem Text="Australia" />
                        <telerik:RadListBoxItem Text="Brazil" />
                        <telerik:RadListBoxItem Text="Canada" />
                        <telerik:RadListBoxItem Text="Chile" />
                        <telerik:RadListBoxItem Text="China" />
                        <telerik:RadListBoxItem Text="Egypt" />
                        <telerik:RadListBoxItem Text="England" />
                    </Items>
                </telerik:RadListBox>
                <telerik:RadListBox ID="RadListBoxDestination" runat="server" Height="200px" />
                <telerik:RadButton EnableSplitButton="true" ID="SplitButton" AutoPostBack="false"
                    runat="server" Text="Transfer Item" OnClientClicked="OnClientClicked">
                </telerik:RadButton>
                <telerik:RadContextMenu ID="RadContextMenu1" runat="server" OnClientItemClicked="OnClientItemClicked">
                    <Items>
                        <telerik:RadMenuItem Text="Transfer Right">
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Transfer Left">
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadContextMenu>
            </div>
        </telerik:RadAjaxPanel>
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function OnClientClicked(sender, args) {

                    if (args.IsSplitButtonClick() || !sender.get_commandName()) {
                        var currentLocation = $telerik.getLocation(sender.get_element());
                        var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
                        contextMenu.showAt(currentLocation.x, currentLocation.y + 22);
                    } else if (sender.get_commandName() == "TransferRight") {
                        transferRight();
                    }
                    else {
                        transferLeft();
                    }
                }

                function OnClientItemClicked(sender, args) {
                    var itemText = args.get_item().get_text();
                    var splitButton = $find("<%= SplitButton.ClientID %>");
                    if (itemText == "Transfer Right") {
                        transferRight();
                        splitButton.set_text("Transfer Right");
                        splitButton.set_commandName("TransferRight");
                    }
                    else if (itemText == "Transfer Left") {
                        transferLeft();
                        splitButton.set_text("Transfer Left");
                        splitButton.set_commandName("TransferLeft");
                    }
                }

                function transferRight() {
                    var listBox2 = $find("<%= RadListBoxSource.ClientID %>");

                    var selectedItem = listBox2.get_selectedItem();
                    if (selectedItem == null) {
                        alert("You need to select a item first.");
                        return false;
                    }

                    listBox2.transferToDestination(selectedItem);
                    return false;
                }

                function transferLeft() {
                    var listBox2 = $find("<%= RadListBoxSource.ClientID %>");
                    var listBox3 = listBox2.get_transferTo();
                    var selectedItem = listBox3.get_selectedItem();
                    if (selectedItem == null) {
                        alert("You need to select a item first.");
                        return false;
                    }

                    listBox2.transferFromDestination(selectedItem);
                    return false;
                }
            </script>
        </telerik:RadCodeBlock>
        <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