1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / RadEditor / Generic Content inserting Body tags

RadEditor / Generic Content inserting Body tags

3 posts, 0 answered
  1. Adam
    Adam avatar
    63 posts
    Registered:
    30 Jan 2008
    22 Jan 2009
    Link to this post
    I have altered the RadEditor configuration to allow javascripts by adding the following attribute to the RadEditor control in the EditorTemplate.ascx file:

    ContentFilters="EncodeScripts"

    This succesfully allows Javascript code to be inserted into the HTML edit mode, but it also comes with <body> </body> tags that I can't seem to be able to get rid of.  How do I get rid of the Body tags? 

    Adam
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    23 Jan 2009
    Link to this post
    Hello Adam,

    Please give a try to the code below. It should strip the <body> tag. Here we are implementig a custom filter using javascript.

    Example:

    <telerik:RadEditor  
                                    ID="contentEditor"  
                                    runat="server"  
                                    ContentAreaCssFile="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorContentArea.css" 
                                    ToolsFile="~/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml"                                 
                                    Skin="WebBlue"  
                                    DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css" 
                                    NewLineBr="False" 
                                    Width="95%" 
                                    OnClientLoad="OnClientLoad"                                 
                                    >  
                                    <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" /> 
                                    <MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
                                    <FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
                                    <DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" /> 
                                    <CssFiles> 
                                        <telerik:EditorCssFile Value="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorCssFile.css" /> 
                                    </CssFiles> 
                                </telerik:RadEditor> 
                                <script type="text/javascript"
                            function OnClientLoad(editor, args) 
                                { 
                                   editor.get_filtersManager().add(new MyFilter()); 
                                } 
                                MyFilter = function() 
                                { 
                                   MyFilter.initializeBase(this); 
                                   this.set_isDom(false); 
                                   this.set_enabled(true); 
                                   this.set_name("RadEditor filter"); 
                                   this.set_description("RadEditor filter description"); 
                                   alert("filter loaded"); 
                                } 
                                MyFilter.prototype = 
                                { 
                                   getHtmlContent : function(content) 
                                   { 
                                     var newContent = content
                                     //Make changes to the content and return it 
                                     newContentnewContent = newContent.replace(/&lt;body&gt;/g, ""); 
                                     return newContent; 
                                   }, 
                                   
                                   getDesignContent : function(content) 
                                   { 
                                     var newContent = content
                                     //Make changes to the content and return it 
                                     newContentnewContent = newContent.replace(/&lt;body&gt;/g,""); 
                                     return newContent; 
                                   } 
                                } 
                                MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter); 

    Let us know about the results.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Adam
    Adam avatar
    63 posts
    Registered:
    30 Jan 2008
    27 Jan 2009
    Link to this post

    I also submitted a support ticket to the main telerik site and I received a much easier answer:

    I changed the ContentFilter property from:

    ContentFilters="EncodeScripts"

    To:

    ContentFilters="EncodeScripts, ConvertToXhtml"

    I did this on ever RadEditor I could find in the sitefinity/admin folder and that did the trick.  Thank-you for your response! 

    Here's the full response from my support ticket.  Hopefully it will be useful should anyone else run into this:


    ------------------------------------

    The version you are using had this problem when the ConvertToXhtml filter is turned off. This filter is the most important of them all. The problem has been subsequently fixed.

     

    There are two options for you to solve the issue -

     

    1) To update to the latest Telerik.Web.UI.dll

    2) To enable the ConvertToXhtml filter, e.g.&nbsp; ContentFilters="EncodeScripts, ConvertToXhtml"

     

    We hope this helps,

     

    Tervel

    the Telerik team

     
    ---------------------------------------

    Thanks,
    Adam

Register for webinar
3 posts, 0 answered