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

Persisting Custom Colors?

2 Answers 31 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Mark Kucera
Top achievements
Rank 1
Mark Kucera asked on 19 May 2010, 10:46 PM
I'm using the RadControls v2010.1.309.35


With the rad editor is there a way to persist custom colors so that when a user comes back their custom colors are retained?  i'm fine with using a cookie approach if necessary so that the custom colors are user/browser specific.

Thanks!
-Mark

2 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 20 May 2010, 01:11 PM
Hi Mark,

RadEditor populates its color collection on the client (on the first loading of the ColorPicker dropdown) and it is not accessible on the server, so in order to preserve the custom colors that were added. As a workaround I suggest you to pass the client-side color collection on the server upon postback using an Hidden Field, e.g.:
Copy Code
<telerik:RadEditor ID="RadEditor1" runat="server">
</telerik:RadEditor>
 
<asp:Button ID="Button1" runat="server" Text="Button1" OnClientClick="beforePostbackHandler()" />
 
<input type="hidden" id="colorArray" runat="server" />
 
<script type="text/javascript">
    var beforePostbackHandler = function()
    {
        var editor = $find("<%= RadEditor1.ClientID %>");
        var colorArray = document.getElementById("colorArray");
 
        colorArray.value = editor.get_colors();
    }
</script>

and after that add these colors to the server-side collection on pageLoad, e.g.:
Copy Code
protected void Page_Load(object sender, EventArgs e)
{
    if (colorArray.Value != "")
    {
        string[] colors = colorArray.Value.Split(new char[]{','});
 
        for (int i = 0; i < colors.Length; i++)
        {
            RadEditor1.Colors.Add(colors[i]);
        }
    }
}


Once you receive the custom colors you can save them in a database and load them depending on the logged user.

Greetings,
Rumen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mark Kucera
Top achievements
Rank 1
answered on 20 May 2010, 08:44 PM
Thanks Rumen, for the most part i was able to take this as is and make it work.    I set it up using cookies as the storage method which will work for our scenario.  We have lots of controls and postbacks on this page so figuring out where to insert the save/update/load code to some work but otherwise i think this will work just fine.  I appreciate the quick reply.

-Mark
Tags
Editor
Asked by
Mark Kucera
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Mark Kucera
Top achievements
Rank 1
Share this question
or