Save Content

2 posts, 0 answers
  1. Michael
    Michael avatar
    18 posts
    Member since:
    Jun 2009

    Posted 15 Feb 2010 Link to this post

    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">



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



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



    "body1").text = sBody1;



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



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


    //click it programmatically








    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 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?

  2. Dobromir
    Dobromir avatar
    1633 posts

    Posted 17 Feb 2010 Link to this post

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