Property or Client API for most recent colors?

2 posts, 1 answers
  1. Mike
    Mike avatar
    11 posts
    Member since:
    Jul 2010

    Posted 18 Jun 2011 Link to this post

    I've setup controls for selecting a color almost identical to the RadColorPicker first look demo. I would like to persist the list of most recent colors as the user chooses a different preset. Currently what happens, like the first look demo, is when the preset is changed then the list of most recent colors is cleared out. I could see someone spending time coming up with color swatches and then switching to view different presets and becoming frustrated when the lost the colors they had queued up in the most recent colors list. Is there any way I can accomplish this?
  2. Answer
    Slav avatar
    1351 posts

    Posted 20 Jun 2011 Link to this post

    Hello Mike,

    Currently there is no Client API for recent colors manipulation. Nonetheless, you can accomplish what you want by using the client-side _recentColors collection and _updateRecentColors method of RadColorPicker. With _recentColors you can get the last colors and then store the result in order to persist them through postback. Afterwards call _updateRecentColors to display the specified colors as the most recently used.

    Below is an example of manually adding recent colors in a RadColorPicker:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            <telerik:RadColorPicker runat="server" ID="RadColorPicker1" PaletteModes="All" CssClass="ColorPickerPreview"
            <asp:Button ID="Button1" runat="server" Text="Button" />
        <script type="text/javascript">
            Sys.Application.add_init(function () {
                $find("<%= RadColorPicker1.ClientID %>")._recentColors = ["#eee", "#ddd"];
            Sys.Application.add_load(function () {
                $find("<%= RadColorPicker1.ClientID %>")._updateRecentColors();

    Note that the client-side script is placed outside the form tag.

    Best wishes,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Telerik UI for ASP.NET Core is out
Back to Top