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

[Solved] Parent id/class for editor content?

1 Answer 86 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Eric Johnson
Top achievements
Rank 1
Eric Johnson asked on 02 Dec 2009, 05:25 PM
Is it possible to set a parent id or class to an Editor so that all of the actual content will be considered a child of that id/class when css is applied in design/preview?  I have a site where the text being entered via the Editor will always be displayed inside a div with id="content" and would like the Editor to display the appropriate styles from my external css file without having to include that div in the content.

Any help or advice would be greatly appreciated.

Eric

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 03 Dec 2009, 01:37 PM
Hi Eric,

You can assign an ID and class attributes to the Body element of the editor document using the following script code:

<style type="text/css">
   .MyClass { background-color: red; }
</style>
 
<script type="text/javascript">
function OnClientLoad(editor)
{
    var editorDocument = editor.get_document();
    editorDocument.body.setAttribute("id", "MyID");
    editorDocument.body.className = "MyClass";
}
</script>
<telerik:RadEditor ID="RadEditor" OnClientLoad="OnClientLoad" runat="server"></telerik:RadEditor>

I hope that this will be useful for your scenario.

Greetings,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Eric Johnson
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or