getting the "Rad Editor" Content Value throgh Java Script

4 posts, 0 answers
  1. Darryl Henderson
    Darryl Henderson avatar
    8 posts
    Member since:
    Mar 2008

    Posted 29 Apr 2009 Link to this post

    how to get the "Rad Editor" Control Content  value at the ClientSide (java Script), without postback.

    Thanks & Regards
    Srinivas
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Apr 2009 Link to this post

    Hi Srinivas,

    You can use either get_text() or get_html() for getting the content of RadEditor in client side. The get_html() returns the editor content as HTML and get_text() returns the editor content as plain text.

    .aspx
     
    <telerik:radeditor id="RadEditor1" runat="server" ToolbarMode="ShowOnFocus"         
    </telerik:radeditor>    
    <input id="Button1" type="button" value="Get Content" onclick="Content();" /> 

    .javascript
     
    <script type="text/javascript">    
    function Content()    
    {    
        var editor = $find("<%=RadEditor1.ClientID%>");    
        var message = editor.get_text(); //get the editor content as plain text    
        alert(message); //alert the plain text content    
    }    
    </script> 

    Checkout the following link for important RadEditor client side methods.
    Getting familiar with Client-Side API

    -Princy.
  3. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 30 Apr 2009 Link to this post

    Hi Darryl Henderson,

    For this purpose you could use the get_text() or get_html() methods (get_html(true) will return the HTML content that is already modified by the editor's client filters.
    e.g:

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadEditor ID="RadEditor1" runat="server"
    </telerik:RadEditor> 
    <button onclick="getContent('html'); return false;">get HTML content</button><br /> 
    <button onclick="getContent('text'); return false;">get text content</button> 
    <script type="text/javascript"
    function getContent(arg) 
        var editor = $find("<%= RadEditor1.ClientID %>");  
        if(arg == "html") 
        { 
            alert("RadEditor HTML content: \n \n" + editor.get_html());  
        } 
        else 
        { 
            alert("RadEditor Text content: \n \n" + editor.get_text());  
        } 
     
    </script> 

    Note that for the native ASP.NET AJAX $find() method to work, you must have an asp:scriptmanager or telerik:radscriptmanager control on your page.
    More information on RadEditor's client-side API is available here.

    All the best,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. vishwa
    vishwa avatar
    1 posts
    Member since:
    Dec 2008

    Posted 19 Jun 2012 Link to this post

    Hi Princy,

    Its worked for me !!!

    Thanks
    Vishwa
Back to Top