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

Default font properties for content saved

1 Answer 86 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ola Karlsson
Top achievements
Rank 1
Ola Karlsson asked on 16 Dec 2010, 07:53 AM
Hi,

I'm trying to set the default font properties of the saved content.

I've got a RadEditor control, I'm setting the default font and text color for the editor like below:
<telerik:RadEditor runat="server"  ID="RadEditor1">
          <CssFiles>
              <telerik:EditorCssFile Value="~/EditorContentArea.css" />
          </CssFiles>
        </telerik:RadEditor>
Which works fine in the editor, however, when I save the content, using RadEditor1.Content, that styling isn't kept.

How can I set the default font and text color so that it gets saved when I save the content?

Cheers,
Ola

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 16 Dec 2010, 05:24 PM
Hi Ola Karlsson,

The css file(s) loaded through the CssFiles property just styles the content area, but it does not apply font tags or inline font-style / font-size styles.

What you can do is to import the same css file(s) in the public page where the content from the database will be displayed.

Another approach is to wrap the initial content or the empty content of RadEditor in a span tag with the desired default font formatting, e.g.

<telerik:radeditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">
    <Content>test</Content>
</telerik:radeditor>
<script type="text/javascript">
    function OnClientLoad(editor) {
        setTimeout(function () {
            var tool = editor.getToolByName("RealFontSize");
            tool.set_value("12px");
            editor.fire("SelectAll");
            editor.fire("FontName", { value: "Arial" });
            var args = new Telerik.Web.UI.EditorCommandEventArgs("RealFontSize", null, "32px");
            editor.fire("RealFontSize", args);
        }, 0);
    }
</script>

The inserted span tags with inline styles by the RealFontSize and FontName will be saved in the database. You can modify the values depending on your requirements. This could be helpful for your scenario.

Best regards,
Rumen
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
Editor
Asked by
Ola Karlsson
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or