RadEditor convert span to font

3 posts, 0 answers
  1. Anisia Alexandra
    Anisia Alexandra avatar
    2 posts
    Member since:
    Apr 2015

    Posted 10 Apr 2015 Link to this post

    I have an application page with 2 RadEditors on it. 

    People enter content in one of the two and by clicking a button they submit the content to a Note field in SharePoint 2010( which is rich text, not enhanced rich text). Submission is done via C# custom code. 

    My issue is that when I try to set the value of the field font name, font size, underline, font color and back color are stripped down in the field. My guess is that the field does not accept XHtml (correct my if I am wrong) so when I try to set the field value with the content :

     <span style="font-family: Arial; font-size: 48px;"><strong><em><span style="background-color: #ffff00; color: #ff0000; text-decoration: underline;">test</span></em></strong></span> which comes from RadEditor, some of these value do not get converted to something like:

    <font style="background-color:#ffff00" color="#ff0000" size="7" face="Arial"><strong><em><u>Anisia 567</u></em></strong></font> that the field is expecting.

     This behavior is occuring with both of my RadEditors.

    The configuration of editor is as follows:

    <telerik:RadEditor runat="server" ID="TextBoxRich" EmptyMessage="msg1" Height="67px" Width="100%" BackColor="#dae4f1" CssClass="noteTextBox" BorderColor="Black" ToolTip="msg2">
                                                                <telerik:EditorTool Name="FontName"/>
                                                                <telerik:EditorTool Name="FontSize"/>
                                                                <telerik:EditorTool Name="Bold"/>
                                                                <telerik:EditorTool Name="Italic"/>
                                                                <telerik:EditorTool Name="Underline"/>
                                                                <telerik:EditorTool Name="JustifyLeft"/>
                                                                <telerik:EditorTool Name="JustifyCenter"/>
                                                                <telerik:EditorTool Name="JustifyRight"/>
                                                                <telerik:EditorTool Name="InsertOrderedList"/>
                                                                <telerik:EditorTool Name="InsertUnorderedList"/>
                                                                <telerik:EditorTool Name="Outdent"/>
                                                                <telerik:EditorTool Name="Indent"/>
                                                                <telerik:EditorTool Name="ForeColor"/>
                                                                <telerik:EditorTool Name="BackColor"/>

    and in ShaPoint I set the value as follows:

    SPFieldMultiLineText field = (SPFieldMultiLineText)Item.Fields["Note"];
     field.ParseAndSetValue(newItem, TextBoxRich.Content);

    Any suggestion is greatly appreciated.

     Thank you.

    Best regards,

    Anisia Pop

  2. Marin Bratanov
    Marin Bratanov avatar
    5929 posts

    Posted 10 Apr 2015 Link to this post

    Hi Anisia,

    You can easily confirm what the SP field does by providing your own HTML string to test what it stores.

    As for RadEditor - if you want to get more <font> elements, try disabling the ConvertFontToSpan filter: http://www.telerik.com/help/aspnet-ajax/editor-content-filters.html.

    The first HTML snippet provided is valid and semantic HTML, so this is what the output from the editor is supposed to look like. If the ConvertFontsToSpan filter does not help for your case, you would need to either create your own filter, or use other custom logic to change the HTML into something you need.


    Marin Bratanov

    See What's Next in App Development. Register for TelerikNEXT.

  3. Anisia Alexandra
    Anisia Alexandra avatar
    2 posts
    Member since:
    Apr 2015

    Posted 13 Apr 2015 in reply to Marin Bratanov Link to this post

    Thank you for the answer.

    Disabling some filters did the trick.

    I disabled the following :



    and added a link to the legacy inline commands:

    <script type="text/javascript" src="<%= Page.ClientScript.GetWebResourceUrl(typeof(RadEditor), "Telerik.Web.UI.Editor.RadEditor.Commands.LegacyInlineCommands.js") %>"></script>

    Have a good day.


Back to Top