<%@ 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>