Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ColorPicker > Property or Client API for most recent colors?

Answered Property or Client API for most recent colors?

Feed from this thread
  • Mike avatar

    Posted on Jun 18, 2011 (permalink)

    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?

    Reply

  • Answer Slav Slav admin's avatar

    Posted on Jun 20, 2011 (permalink)

    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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <telerik:RadColorPicker runat="server" ID="RadColorPicker1" PaletteModes="All" CssClass="ColorPickerPreview"
                ShowRecentColors="True">
            </telerik:RadColorPicker>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        </form>
        <script type="text/javascript">
            Sys.Application.add_init(function () {
                $find("<%= RadColorPicker1.ClientID %>")._recentColors = ["#eee", "#ddd"];
            });
            Sys.Application.add_load(function () {
                $find("<%= RadColorPicker1.ClientID %>")._updateRecentColors();
            });
        </script>
    </body>
    </html>

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

    Best wishes,
    Slav
    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ColorPicker > Property or Client API for most recent colors?
Related resources for "Property or Client API for most recent colors?"

ASP.NET ColorPicker Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]