This is a migrated thread and some comments may be shown as answers.

RadEditor convert span to font

2 Answers 109 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Anisia Alexandra
Top achievements
Rank 1
Anisia Alexandra asked on 10 Apr 2015, 09:59 AM

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">
                                                    <Tools>
                                                        <telerik:EditorToolGroup>
                                                            <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"/>
                                                        </telerik:EditorToolGroup>
                                                    </Tools>
                                                </telerik:RadEditor>  

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 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 10 Apr 2015, 02:15 PM

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.

Regards,

Marin Bratanov
Telerik
 

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

 
0
Anisia Alexandra
Top achievements
Rank 1
answered on 13 Apr 2015, 06:39 AM

Thank you for the answer.

Disabling some filters did the trick.

I disabled the following :

ConvertTags
FixUlBoldItalic

ConvertFontToSpan

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.

Anisia

Tags
Editor
Asked by
Anisia Alexandra
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Anisia Alexandra
Top achievements
Rank 1
Share this question
or