Default font settings

2 posts, 0 answers
  1. Harsh
    Harsh avatar
    4 posts
    Member since:
    Sep 2012

    Posted 13 May 2013 Link to this post

    I have set the default font setting using the shown below js
    The script works fine and can see intended font changes when I switch to preview mode
    but in HTMLedit view intended HTML font tags and attribute are not seen
    and hence when I get the content of Radeditor using

    rdEditor.Content property it does not include the default settings(font attributes ) and intended font changes 

    rdEditor.OnClientLoad = "OnClientLoad";
           string js = @"
       <script language='javascript'>
           function OnClientLoad(editor, args) {
                     var style = editor.get_contentArea().style;
                     style.fontFamily= 'Calibri';
                     style.fontSize= 11 + 'pt';
                     style.color = '#1f497d';
               }, 100);
           Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "myscriptkey", js);
  2. Rumen
    Rumen avatar
    14220 posts

    Posted 13 May 2013 Link to this post


    Indeed, the code that you use applies font family, size and color to the content area of the editor. This has nothing to do, however, with the contents loaded in this content area.

    What you can do is to wrap the contents in some span tag with the desired font formatting.
    You can use the following code solution to wrap the initial content or the empty content of RadEditor in a span tag with Calibri 11px, e.g.

    <telerik:radeditor runat="server"OnClientLoad="OnClientLoad"ID="RadEditor1">
    <script type="text/javascript">
    function OnClientLoad(editor) {
      setTimeout(function() {
       var tool = editor.getToolByName("RealFontSize");
       var args = newTelerik.Web.UI.EditorCommandEventArgs("RealFontSize", null,     "11px");"RealFontSize", args);"FontName", { value: "Calibri"});
    }, 0);

    Another way is to wrap the obtained content on the server in a span tag having the desired font-size style in pixels, e.g.

    RadEditor1.Content = "<span style='font-family: Calibri;font-size: 11px;'>" + RadEditor1.Content + "</span>";

    Best regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top