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

getting the "Rad Editor" Content Value throgh Java Script

3 Answers 638 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Darryl Henderson
Top achievements
Rank 1
Darryl Henderson asked on 29 Apr 2009, 03:44 PM
how to get the "Rad Editor" Control Content  value at the ClientSide (java Script), without postback.

Thanks & Regards
Srinivas

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Apr 2009, 07:34 AM
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.
0
Georgi Tunev
Telerik team
answered on 30 Apr 2009, 07:36 AM
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.
0
vishwa
Top achievements
Rank 1
answered on 19 Jun 2012, 10:50 PM
Hi Princy,

Its worked for me !!!

Thanks
Vishwa
Tags
Editor
Asked by
Darryl Henderson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Georgi Tunev
Telerik team
vishwa
Top achievements
Rank 1
Share this question
or