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

Change background color in editor

4 Answers 135 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 10 Dec 2008, 02:58 PM
I know this can be done but I don't know how! :)

I have an radEditor and a radColorPicker.
Now, I want to change the editors background color when selecting a color, how do I do that?

/Mattias

4 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 10 Dec 2008, 03:52 PM
Hi Mattias,

This one should be easy. You need to attach to the OnClientColorChange or OnClientColorSelecting event of RadColorPicker and obtain the selected color. After that set it as a value to the editor.get_contentArea().style.backgroundColor = "color value returned by RadColorPicker".

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mattias
Top achievements
Rank 1
answered on 10 Dec 2008, 04:07 PM
Got it! :)

<telerik:RadColorPicker ID="radColorPickerBackgroundColor" runat="server"  
                                    Preset="Default" OnClientColorChange="HandleClientValueChange"
                                </telerik:RadColorPicker> 
                            
                                <telerik:RadEditor ID="radEditorText" Runat="server" Height="334px" Width="221px"
                                   <CssFiles> 
                                        <telerik:EditorCssFile Value="/Style/PublicStyle.css" /> 
                                    </CssFiles> 
                                       </telerik:EditorToolGroup> 
                                </telerik:RadEditor> 
<script type="text/javascript"
                        function HandleClientValueChange(sender, eventArgs) { 
                            var editor = $find("<%=radEditorText.ClientID%>"); 
                            var style = editor.get_contentArea().style; 
                            style.backgroundColor = sender.get_selectedColor(); 
                        } 
                    </script> 

0
Mattias
Top achievements
Rank 1
answered on 11 Dec 2008, 08:26 AM
Hmm, how can I set it code behind?
Have tried with:
radEditorText.Style.Add(HtmlTextWriterStyle.BackgroundColor, CurrentBanner.BackgroundColor);
and
radEditorText.BackColor = ColorTranslator.FromHtml(CurrentBanner.BackgroundColor);
but it seems to have no effect!




0
Rumen
Telerik team
answered on 11 Dec 2008, 09:26 AM
Hi Mattias,

Currently, you can use only the client-side solution, because the server BackColor property is inherited from the base control of RadEditor and it is not yet implemented. If you want to have a server-side solution, you could import the javascript code from the codebehind using the ScriptManager.RegisterClientScriptBlock() server method.

Best regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ColorPicker
Asked by
Mattias
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Mattias
Top achievements
Rank 1
Share this question
or