This is a migrated thread and some comments may be shown as answers.

Property or Client API for most recent colors?

1 Answer 31 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 18 Jun 2011, 10:11 PM
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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 20 Jun 2011, 01:19 PM
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.

Tags
ColorPicker
Asked by
Mike
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or