This is a migrated thread and some comments may be shown as answers.
How to get cleaner html from RichTextBox
3 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
papadi
Top achievements
Rank 1
papadi asked on 26 Sep 2012, 12:18 PM
Hi!
I'm using a RichTextBox with an HtmlDataProvider. When the end user writes this "aaaaaaaa" in the editor the return value of the HtmlDataProvider returns the following huge text when I would expect to get this:
aaaaaaaa 
or perhaps this
<p>aaaaaaaa</p>

How can I change this?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled</title><style type="text/css">
p { margin-top: 0px;margin-bottom: 12px;line-height: 1.15;text-align: left; }
body { font-family: 'Segoe UI';font-style: Normal;font-weight: normal;font-size: 12px; }
.TableNormal { telerik-style-type: table;telerik-style-name: TableNormal; }
.TableGrid { telerik-style-type: table;telerik-style-name: TableGrid;telerik-based-style-name: TableNormal;margin-bottom: 0px;line-height: 1; }
.Normal { telerik-style-type: paragraph;telerik-style-name: Normal; }
.Heading1 { telerik-style-type: paragraph;telerik-style-name: Heading1;telerik-based-style-name: Normal;telerik-linked-style-name: Heading1Char;font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 32px;margin-bottom: 0px; }
.Heading1Char { telerik-style-type: character;telerik-style-name: Heading1Char;telerik-linked-style-name: Heading1;font-weight: bold;font-size: 18.6666660308838px;color: #4F81BD;margin-top: 32px;margin-bottom: 0px; }
.Heading2 { telerik-style-type: paragraph;telerik-style-name: Heading2;telerik-based-style-name: Normal;telerik-linked-style-name: Heading2Char;font-weight: bold;font-size: 17.3333339691162px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading2Char { telerik-style-type: character;telerik-style-name: Heading2Char;telerik-linked-style-name: Heading2;font-weight: bold;font-size: 17.3333339691162px;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading3 { telerik-style-type: paragraph;telerik-style-name: Heading3;telerik-based-style-name: Normal;telerik-linked-style-name: Heading3Char;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading3Char { telerik-style-type: character;telerik-style-name: Heading3Char;telerik-linked-style-name: Heading3;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading4 { telerik-style-type: paragraph;telerik-style-name: Heading4;telerik-based-style-name: Normal;telerik-linked-style-name: Heading4Char;font-style: Italic;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading4Char { telerik-style-type: character;telerik-style-name: Heading4Char;telerik-linked-style-name: Heading4;font-style: Italic;font-weight: bold;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading5 { telerik-style-type: paragraph;telerik-style-name: Heading5;telerik-based-style-name: Normal;telerik-linked-style-name: Heading5Char;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading5Char { telerik-style-type: character;telerik-style-name: Heading5Char;telerik-linked-style-name: Heading5;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading6 { telerik-style-type: paragraph;telerik-style-name: Heading6;telerik-based-style-name: Normal;telerik-linked-style-name: Heading6Char;font-style: Italic;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading6Char { telerik-style-type: character;telerik-style-name: Heading6Char;telerik-linked-style-name: Heading6;font-style: Italic;color: #4F81BD;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading7 { telerik-style-type: paragraph;telerik-style-name: Heading7;telerik-based-style-name: Normal;telerik-linked-style-name: Heading7Char;font-style: Italic;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading7Char { telerik-style-type: character;telerik-style-name: Heading7Char;telerik-linked-style-name: Heading7;font-style: Italic;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading8 { telerik-style-type: paragraph;telerik-style-name: Heading8;telerik-based-style-name: Normal;telerik-linked-style-name: Heading8Char;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading8Char { telerik-style-type: character;telerik-style-name: Heading8Char;telerik-linked-style-name: Heading8;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading9 { telerik-style-type: paragraph;telerik-style-name: Heading9;telerik-based-style-name: Normal;telerik-linked-style-name: Heading9Char;font-style: Italic;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Heading9Char { telerik-style-type: character;telerik-style-name: Heading9Char;telerik-linked-style-name: Heading9;font-style: Italic;font-size: 13.3333330154419px;color: #000000;margin-top: 13.3333330154419px;margin-bottom: 0px; }
.Caption { telerik-style-type: paragraph;telerik-style-name: Caption;telerik-based-style-name: Normal;font-family: 'Calibri';font-weight: bold;font-size: 12px;color: #4F81BD;line-height: 1; }
.TOC1 { telerik-style-type: paragraph;telerik-style-name: TOC1;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px; }
.TOC2 { telerik-style-type: paragraph;telerik-style-name: TOC2;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 14.6666669845581px; }
.TOC3 { telerik-style-type: paragraph;telerik-style-name: TOC3;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 29.3333339691162px; }
.TOC4 { telerik-style-type: paragraph;telerik-style-name: TOC4;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 44.0000009536743px; }
.TOC5 { telerik-style-type: paragraph;telerik-style-name: TOC5;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 58.6666679382324px; }
.TOC6 { telerik-style-type: paragraph;telerik-style-name: TOC6;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 73.3333349227905px; }
.TOC7 { telerik-style-type: paragraph;telerik-style-name: TOC7;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 88.0000019073486px; }
.TOC8 { telerik-style-type: paragraph;telerik-style-name: TOC8;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 102.666668891907px; }
.TOC9 { telerik-style-type: paragraph;telerik-style-name: TOC9;telerik-based-style-name: Normal;margin-bottom: 6.66666650772095px;margin-left: 117.333335876465px; }
.TableofFigures { telerik-style-type: paragraph;telerik-style-name: TableofFigures;telerik-based-style-name: Normal;margin-bottom: 0px; }
.Hyperlink { telerik-style-type: character;telerik-style-name: Hyperlink;color: #0000FF;text-decoration: underline; }
.p_DEC438A7 { telerik-style-type: local; }
.s_DEC438A7 { telerik-style-type: local; }
</style></head><body><p class="Normal p_DEC438A7"><span class="s_DEC438A7">aaaaaaaa</span></p></body></html>


3 Answers, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 27 Sep 2012, 10:49 AM
Hi Dimitrios,

We have import/export settings on HtmlFormatProvider which you can use in different combinations to suit the needs of your project. You can read about them in this article


Kind regards,
Mihail
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
papadi
Top achievements
Rank 1
answered on 27 Mar 2013, 10:37 AM
Using the export settings significantly improves the situation, but still the result when the user writes aaaaa is the following:

<p style="margin-top: 0px;margin-bottom: 12px;line-height: 1.15;text-align: left;"><span style="font-family: 'Tahoma';font-size: 14px;">gggg</span></p>

In this case I would expect not to get any styling at all, since my user didn't enter any. Especially the margin and line height information seem really random.

1) What do I do?

2) I see there is a PropertiesToIgnore option in the export settings. But I'm using .NET 3.5 and I think I cannot have this property in the versions of your components for .NET 3.5 right?
0
Mihail
Telerik team
answered on 29 Mar 2013, 09:18 AM
Hello Dimitrios,

Our RadRichTextBox as functionality is closer to a word processor rather than an html editor. That's the reason why we do our best to keep the exact formatting of the content when exporting.

PropertiesToIgnore were implemented after the support for .NET 3.5 was discontinued, so it is not available for this version of the platform.

Kind regards,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
papadi
Top achievements
Rank 1
Answers by
Mihail
Telerik team
papadi
Top achievements
Rank 1
Share this question
or