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

Update RadEditor using Javascript

1 Answer 286 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 04 Sep 2013, 08:55 PM
I am trying to update the contents of the control using Javascript.   I can update the value of a simple text box but not the RadEditor.  

In order to update a simple aspx textbox I use the code

var editor = document.getElementById('<%= txtTest.ClientID %>');

editor.value = "some text";

How do i do the same for a RadEditor rich text box?   

Thanks.

(I am using the lastest version of the control)

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Sep 2013, 11:59 AM
Hi Patrick,

Our controls have their own client-side objects that are obtained through the $find() method from the MS AJAX framework and you need to use their API in order to modify them:
http://www.telerik.com/help/aspnet-ajax/editor-getting-reference-to-radeditor.html
http://www.telerik.com/help/aspnet-ajax/editor-getting-familiar-with-client-side-api.html

So, here is an example of setting some HTML in RadEditor:
var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client object
editor.set_html("<strong>I am text that is  bold</strong>"); //set some content

More about the set_html() method is available here: http://www.telerik.com/help/aspnet-ajax/editor-set-html.html

Regards,
Marin Bratanov
Telerik
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 the blog feed now.
Tags
Editor
Asked by
Patrick
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or