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

seting default settings in editor

3 Answers 74 Views
Editor
This is a migrated thread and some comments may be shown as answers.
tasos
Top achievements
Rank 1
tasos asked on 21 Mar 2012, 12:13 PM
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.

3 Answers, 1 is accepted

Sort by
0
tasos
Top achievements
Rank 1
answered on 23 Mar 2012, 02:23 PM
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?
0
Rumen
Telerik team
answered on 23 Mar 2012, 02:30 PM
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.
0
tasos
Top achievements
Rank 1
answered on 23 Mar 2012, 02:36 PM
Thanks Rumen.
Tags
Editor
Asked by
tasos
Top achievements
Rank 1
Answers by
tasos
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or