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

How to achieve set_text function like get_text

1 Answer 133 Views
Editor
This is a migrated thread and some comments may be shown as answers.
ARUNTHOMAS
Top achievements
Rank 1
ARUNTHOMAS asked on 03 Feb 2011, 10:52 AM
Hi Telerik,
I need to achieve the fuction set_text like get_text.Because i append some text from database .That why i am asking.......
Thank you.

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 03 Feb 2011, 01:13 PM
Hi ARUNTHOMAS,

RadEditor does not offer a method named set_text. To set the content in the editor you should use the editor's set_html() method. If you want to load plain text you should strip the HTML markup before setting the content using some regular expression. Here is a base example:

<telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
<input type="button" onclick="SetPlainText();return false;" value="Set Plain Text" />
<script type="text/javascript">
    function SetPlainText() {
        var editor = $find("<%=RadEditor1.ClientID%>");
        var content = "<strong><i>test</i></strong>";
        var plainTextContent = content.replace(/<\/?[^>]*>/ig, "").replace(/<!--(.|\s)*?-->/gi, "");
        editor.set_html(plainTextContent);
    }
</script>


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
ARUNTHOMAS
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or