seting default settings in editor

4 posts, 0 answers
  1. tasos
    tasos avatar
    26 posts
    Member since:
    Jun 2010

    Posted 21 Mar 2012 Link to this post

    Hello.
    I would like to set some settings in server-side.
    So i want to enable bold and italics and font-size 22px and selected font Arial(those settings depend on user preferences)
    I don't want to use ContentAreaCssFile(which can actually  set the font-weight bold but not make the B button look like it's pressed.Of course i can use js...).
    Any ideas?Thanks.
    
    
  2. tasos
    tasos avatar
    26 posts
    Member since:
    Jun 2010

    Posted 23 Mar 2012 Link to this post

    After searching a little bit i found stuff like:
    var args = new Telerik.Web.UI.EditorCommandEventArgs("RealFontSize", null, "10px");
    tleditor.fire("RealFontSize", args);  
    tleditor.fire("Underline");
    tleditor.fire("Bold");
    etc...

    Can this be done in server-side?
  3. Rumen
    Admin
    Rumen avatar
    14351 posts

    Posted 23 Mar 2012 Link to this post

    Hello,

    You can set the default font and font size programmatically using the following JavaScript code:

    Copy Code
    <telerik:RadEditor ID="RadEditor1" OnClientLoad="OnClientLoad" runat="server"></telerik:RadEditor>
    <script type="text/javascript">
    function OnClientLoad(editor, args) {
    var style = editor.get_contentArea().style;
    style.fontFamily = "Arial";
    style.fontSize = 15 + "px";
    }
    </script>

    If you want to set the font from the server use the following code:

    Copy Code
    <telerik:RadEditor ID="RadEditor1" OnClientLoad="OnClientLoad" runat="server"></telerik:RadEditor>
    <script type="text/c#" runat="server" >
    protected void Page_Load(Object sender, EventArgs e)
    {
       RadEditor1.OnClientLoad = "OnClientLoad";
       string scriptstring = "function OnClientLoad(editor, args) { var style = editor.get_contentArea().style; style.fontFamily = 'Arial'; style.fontSize = 15 + 'px'; }";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "DisableEditor", scriptstring, true);
    }
    </script>


    Greetings,
    Rumen
    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.
  4. tasos
    tasos avatar
    26 posts
    Member since:
    Jun 2010

    Posted 23 Mar 2012 Link to this post

    Thanks Rumen.
Back to Top