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

Save Content

1 Answer 76 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 15 Feb 2010, 12:19 PM
I have the following javascript code for my custom save button in the toolbar. The ID 'editBody1555365' is a div that gets populated inside the content area of the editor.

<

 

asp:Button ID="btnSubmit" runat="server" Text="Save"/>

<

 

asp:Label ID="body1" runat="server" ></asp:Label>

 


<

 

script type="text/javascript">

 

Telerik.Web.UI.Editor.CommandList[

"Save"] = function(commandName, editor, args) {

 

 

var sBody1 = editor.get_document().getElementById("editBody1555365").innerHTML;

 

document.getElementById(

"body1").text = sBody1;

 

alert(

"Body1: " + document.getElementById("body1").text);

 

 

var btnSubmit = $get("<%=btnSubmit.ClientID%>"); //get a reference to the Asp:Button

 

btnSubmit.click();

//click it programmatically

 

};

 

</script>

 

<

 

telerik:RadEditor showSubmitCancelButtons="False" editable="true" SaveInFile="False" ID="RadEditor" runat="server" ></telerik:RadEditor>

 

 

 

When I alert the label I am receiving the content as expected. The problem is when I get inside the code behind for my asp.net button when it gets programmatically clicked it doesnt seem to be able to find any content inside my label 'body1' which it should seeing as it alerted the content just before. It is if the content gets erased when the page does a post back before going inside the save button code behind.

Does anyone know how I can get the content for the ID 'editBody1555365' through the code behind?

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 17 Feb 2010, 03:50 PM
Hi Michael,

The RadEditor's Content property returns a string representing the exact HTML content of the editor. The only possible approach to get the content of an HTML element inside the RadEditor's content is to parse the string manually which is not highly recommended.

The approach that you have taken is the recommended one. There is just an error which is not directly related to RadControls but to general ASP - the only element that will persist its value (Text, innerHTML) upon PostBack is a hidden field.

For your convenience I have attached a sample project that demonstrates how to get the content of an element from inside the RadEditor's content.

All the best,
Dobromir
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Editor
Asked by
Michael
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or