RADEditor & becomes &(&amp)

5 posts, 0 answers
  1. Aslam
    Aslam avatar
    9 posts
    Member since:
    Dec 2010

    Posted 14 Mar 2012 Link to this post

    I have a requirement to wants me to disable the switching "&" into "&amp" (happens when I go to HTML mode from design mode)

    Scenario:
    I would like to use RADEditor to add jQuery pl see attached radeditor.png
    (when RadEditor1.EditModes = Telerik.Web.UI.EditModes.Html)

    When switching from designmode to HTML, mode & becomes &
    (may also apply to "£ converted to &pound")

    Check the post(link below)
    http://www.telerik.com/support/kb/aspnet-ajax/editor/converting-unicode-symbols-to-numeric-html-entities-using-a-content-filter.aspx

    And I tried with Built-in Content Filters.
    http://demos.telerik.com/aspnet-ajax/editor/examples/builtincontentfilters/defaultcs.aspx
    But does not stop from converting & to &amp (also £ to &pound)

    pl see the attached files contentfilter1.png and contentfilter2.png

    Also tried adding code as well as specified in http://www.telerik.com/support/kb/aspnet-ajax/editor/converting-unicode-symbols-to-numeric-html-entities-using-a-content-filter.aspx

    pl can someone help
    A code example to download would be better.

    thanks
    ami
  2. Rumen
    Admin
    Rumen avatar
    14351 posts

    Posted 16 Mar 2012 Link to this post

    Hi Ami,

    My suggestion is to disable the ConvertCharactersToEntities content filter and test the editor.

    Best regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Aslam
    Aslam avatar
    9 posts
    Member since:
    Dec 2010

    Posted 16 Mar 2012 Link to this post

    Hi Rumen,

    thanks for the reply.
    If you are asking to play around the demo
    http://demos.telerik.com/aspnet-ajax/editor/examples/builtincontentfilters/defaultcs.aspx

    by unchecking "ConvertCharactersToEntities" property, then I have already done and then posted here.
    pl see my attachments "contentfilter1.png" and "contentfilter2.png" in previous post.

    if it is someother thing then pl make it more clear.

    regards
    Aslam
  4. Aslam
    Aslam avatar
    9 posts
    Member since:
    Dec 2010

    Posted 20 Mar 2012 Link to this post

    help please?
  5. Rumen
    Admin
    Rumen avatar
    14351 posts

    Posted 20 Mar 2012 Link to this post

    Hi,

    It appeared that this is a Firefox behavior, which can be reproduced in an editable iframe and div elements as the attached one. To fix it you can implement a custom content filter that will replace the & entity with & when switching to HTML mode and submitting the content, e.g.

    <telerik:radeditor id="RadEditor1" ContentFilters="none" onclientload="OnClientLoad" runat="server"></telerik:radeditor>  
        
    <script type="text/javascript">   
        function OnClientLoad(editor, args)   
        {   
           editor.get_filtersManager().add(new RadEditorCustomFilter());   
        }   
        RadEditorCustomFilter = function()   
        {   
           RadEditorCustomFilter.initializeBase(this);   
           this.set_isDom(false);   
           this.set_enabled(true);   
           this.set_name("RadEditor filter");   
           this.set_description("RadEditor filter description");   
        }   
        RadEditorCustomFilter.prototype =   
        {   
           getHtmlContent : function(content)   
           {   
                //Make changes to the content and return it   
                //Convert the & symbol to its HTML & entity
                 newContent = content.replace(/&amp;/gi, "&");     //you should enhance the regular expression because right now it will replace all & symbols in the content with &
      
             return newContent;   
           
        }   
        RadEditorCustomFilter.registerClass('RadEditorCustomFilter', Telerik.Web.UI.Editor.Filter);   
    </script> 


    Regards,
    Rumen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top