New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Icons

Icon with Text

Add Row
  • Add Row
  • Remove Row
  • Edit Row

Icon Only

  • Add Row
  • Remove Row
  • Edit Row

RadSplitButton comes with several options to display an icon in it, providing a large set of built-in icons. You can also use custom icons (image or font icons) and fine-tune their position, color and size.

To use the built-in icons, set the Icon.CssClass property to one of the predefined CSS class names, and the respective icon will be shown inside the Button part of the control.

To use built-in icons in the ContextMenu options of the SplitButton, enable the EnableImageSprite property of the corresponding MenuItem and set the icon class in the SpriteCssClass preceded with the "p-icon" class name.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.Web.Examples.SplitButton.Functionality.Icons.DefaultVB" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <style>
        .colDiv {
            display:inline-block;
            width: 240px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />

    <div class="demo-container size-narrow">
        <script>
            function OnClientItemClicking(sender, args) {
                var itemValue = args.get_item().get_value();

                // not working out-of-the-box
                var primaryCssClass = sender.get_iconData().primaryCssClass;
                sender.set_iconData({ primaryCssClass: itemValue });

                var iconSpan = $telerik.$(sender.get_element()).find(".rbPrimaryIcon");
                iconSpan.removeClass(primaryCssClass);
                iconSpan.addClass(itemValue);
            }

            function OnClientItemClickingNoText(sender, args) {
                var itemValue = args.get_item().get_value();

                args.set_newButtonText("");

                // not working out-of-the-box
                //https://www.telerik.com/forums/how-to-change-primaryicon-at-client-side
                var primaryCssClass = sender.get_iconData().primaryCssClass;
                sender.set_iconData({ primaryCssClass: itemValue });

                var iconSpan = $telerik.$(sender.get_element()).find(".rbPrimaryIcon");
                iconSpan.removeClass(primaryCssClass);
                iconSpan.addClass(itemValue);
            }
        </script>
        <div class="colDiv">
            <h4>Icon with Text</h4>

            <telerik:RadSplitButton runat="server" ID="RadSplitButton1" Text="Add Row" Width="160" AutoPostBack="false" OnClientContextMenuItemClicked="OnClientItemClicking">
                <Icon CssClass="rbAdd" />
                <ContextMenu runat="server">
                    <Items>
                        <telerik:RadMenuItem Text="Add Row" Value="rbAdd" EnableImageSprite="true" SpriteCssClass="p-icon rbAdd"></telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Remove Row" Value="rbRemove" EnableImageSprite="true" SpriteCssClass="p-icon rbRemove"></telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Edit Row" Value="rbEdit" EnableImageSprite="true" SpriteCssClass="p-icon rbEdit"></telerik:RadMenuItem>
                    </Items>
                </ContextMenu>
            </telerik:RadSplitButton>
        </div>
        <div class="colDiv">
             <h4>Icon Only</h4>

            <telerik:RadSplitButton runat="server" ID="RadSplitButton2" Width="60px" AutoPostBack="false" OnClientContextMenuItemClicked="OnClientItemClickingNoText">
                <Icon CssClass="rbAdd" />
                <ContextMenu runat="server">
                    <Items>
                        <telerik:RadMenuItem Text="Add Row" Value="rbAdd" EnableImageSprite="true" SpriteCssClass="p-icon rbAdd"></telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Remove Row" Value="rbRemove" EnableImageSprite="true" SpriteCssClass="p-icon rbRemove"></telerik:RadMenuItem>
                        <telerik:RadMenuItem Text="Edit Row" Value="rbEdit" EnableImageSprite="true" SpriteCssClass="p-icon rbEdit"></telerik:RadMenuItem>
                    </Items>
                </ContextMenu>
            </telerik:RadSplitButton>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance