Set Text In RadEditor

4 posts, 0 answers
  1. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 13 Jan 2012 Link to this post

    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.
  2. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 13 Jan 2012 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 13 Jan 2012 Link to this post

    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.
  5. Rumen
    Admin
    Rumen avatar
    12846 posts

    Posted 13 Jan 2012 Link to this post

    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
Back to Top