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

Set Text In RadEditor

3 Answers 319 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Velkumar
Top achievements
Rank 2
Velkumar asked on 13 Jan 2012, 07:44 AM
Hi,
   I have a radeditor in my page. In radeditor we have the client side function  get_text() to get the text from radeditor. But how to set the text in radeditor instead on set_Html(). The set_html() function has some limitations if the editor contents has special characters or bold, italic etc. Please give the solution for this problem.

Thanks,
Velkumar.

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 13 Jan 2012, 12:23 PM
Hi Velkumar,

To set the content in RadEditor you can use editor.set_html() which support bold, italic and special characters or editor.get_document().body.innerHTML.

If you experience any problems with the set_html method, please provide sample content, steps to reproduce and specify a browser.

Kind regards,
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
Velkumar
Top achievements
Rank 2
answered on 13 Jan 2012, 01:16 PM
Hi,

If we get the text, which is bold in radeditor and again set it in the radeditor using set_html function , the text will displayed in normal.

Thanks,
Velkumar.
0
Rumen
Telerik team
answered on 13 Jan 2012, 06:09 PM
Hello,

Using this code I was unable to reproduce the problem:
<telerik:RadEditor ID="RadEditor1" runat="server">    
    <Tools>   
        <telerik:EditorToolGroup>   
            <telerik:EditorTool Name="GetSetContent" />   
            <telerik:EditorTool Name="Bold" /> 
            <telerik:EditorTool Name="Italic" /> 
        </telerik:EditorToolGroup>   
    </Tools>   
</telerik:RadEditor>   
                  
<script type="text/javascript">
    Telerik.Web.UI.Editor.CommandList["GetSetContent"] = function (commandName, editor, args) {
        var content = editor.get_html(true);
        alert("the obtained content is: " + editor.get_html(true));
        //set the obtained content back in the editor
        editor.set_html(content);
        alert("the content set in RadEditor is: " + editor.get_html(true));
    };    
     
</script>

You can see my test in the following video: http://screencast.com/t/jIvzuvcdKIV.

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
Tags
Editor
Asked by
Velkumar
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Velkumar
Top achievements
Rank 2
Share this question
or