Issue with Save the Rad Editor content in MVC controller

3 posts, 1 answers
  1. Akila Kumarasamy
    Akila Kumarasamy avatar
    25 posts
    Member since:
    Dec 2009

    Posted 30 Aug 2011 Link to this post


    I am trying to use AJAX editor  in MVC framework. I followed these 2 link for the implementation and every thing works fine except saving the content(accessing in controller).

    The issue is when I assign a value to the content of the editor (say some default value) and then modify it and save it, it always saves the assigned value and not the updated value.

    If I remove the default value that is assigned to the editor, then after typying the content in editor when I click save it saves empty, the form value that i get in controller is empty string.

    I checked using fiddler and still the formcollection is having empty value only if there is no default value. If I have a default value it has the default value and not the updated data.

    can some one help with this?

    Another small issue is, I was trying to set the filter ,searchPatten and few more in the MVC view as below, but the Editor dint recognize the paths or the searchpattern or the filters. When I used it as inline it worked. And Inline doesnt allow <%= %>  for MaxUploadFileSize and for searchpatters as the Editor is a server control. So I am forced to use hardcoded value. Is there any alternative for fixing this?
    <% string ImageGalleryPath = "/images/ModuleName";
                EditorID.ImageManager.ViewPaths = new string[] { ImageGalleryPath };
                EditorID.ImageManager.UploadPaths = new string[] { ImageGalleryPath };
                EditorID.ImageManager.DeletePaths = new string[] { ImageGalleryPath };
                EditorID.ImageManager.MaxUploadFileSize = ConfigurationHelper.MaxUploadFileSize;
                EditorID.ImageManager.SearchPatterns = ConfigurationHelper.SearchPatternsImages;


  2. Answer
    Rumen avatar
    14031 posts

    Posted 02 Sep 2011 Link to this post

    Hi Akila,

    RadEditor depends on the "onsubmit" of a form to prepackage the contents into a hidden textarea that gets used. That is why you should save the editor's content in this hidden textarea before submitting the form using the editor.saveContent() method, e.g.

    Could you please try to manually store the RadEditor's content to that text area by calling RadEditor's saveContent() client-side method when submitting the content.

    <asp:Button ID="bSaveMessage" runat="server" Text="Save" OnClientClick="storeEditorsContent(); return false;" />
    <script type="text/javascript">
    function storeEditorsContent()
       var frm = document.getElementById("form1");
       var radEditor = $find("<%=RadEditor1.ClientID%>");

    As to the second question: There is not an alternative way to set the properties values.

    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Akila Kumarasamy
    Akila Kumarasamy avatar
    25 posts
    Member since:
    Dec 2009

    Posted 02 Sep 2011 Link to this post

    Hi Rumen,

    That works great! Thank you very much.

Back to Top