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

Setting the Color

Selected color: #FFFF00

Pick Color(Current Color is #FFFF00)

You can get or set the SelectedColor using the client-side API, using the set_selectedColor(value) or get_selectedColor() method.

Note: The client-side value is always in Hexadecimal format.

In code behind use the SelectedColor property. The selected value has a different CSS class applied to it. When the ShowIcon property is set to true the SelectedColor property will be filled in the icon.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="c#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.ColorPicker.SelectedColor.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ 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>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-containers">
        <div class="demo-container">
            <div class="demo-container no-bg size-custom-large">
                <telerik:RadAjaxPanel runat="server" ID="RadAjaxManager1">
                    <h2>Selected color: <asp:Label runat="server" ID="Label1" Text="#FFFF00"></asp:Label></h2>    
                    <div class="margin-bottom"></div>
                    <telerik:RadColorPicker RenderMode="Lightweight" AutoPostBack="true" OnColorChanged="ColorPicker1_Click" runat="server"
                        SelectedColor="#FFFF00" ID="RadColorPicker1" Preset="Standard" Width="290">
                    </telerik:RadColorPicker>
                </telerik:RadAjaxPanel>
            </div>
            <div class="demo-container no-bg size-custom-small">
                <telerik:RadAjaxPanel runat="server" ID="RadAjaxManager2">
                    <h2>Selected color: <asp:Label runat="server" ID="Label2" Text="#FFFF00"></asp:Label></h2>    
                    <div class="margin-bottom"></div>
                    <div class="colopicker-container">
                        <telerik:RadColorPicker RenderMode="Lightweight" AutoPostBack="true" OnColorChanged="ColorPicker2_Click" runat="server"
                            SelectedColor="#FFFF00" ID="RadColorPicker2" ShowIcon="true" Preset="Standard">
                        </telerik:RadColorPicker>
                    </div>
                </telerik:RadAjaxPanel>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance