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

RichTextBox Text convert To HTML format

20 Answers 1178 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
bob thomash
Top achievements
Rank 1
bob thomash asked on 30 Apr 2010, 10:00 AM
Hello Friends !

I m using visual studio 2010 Ultimate with Silverlight 4.
I m using RIchTxtBox as my email Body in my silverlight Project.

I want to Save RadRichTextBox Text in my database as HTML format

how to convert RadRichTextBox Text into HTML???
Please send me sample Code or project

20 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 30 Apr 2010, 05:17 PM
Hi bob thomash,

Currently RadRichTextBox supports only plain text and XAML formats. We will be adding more formats like HTML, RTF for the official version in Q2. Let us know if we can help further at this point.

Best wishes,
Mike
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Glenn Morton
Top achievements
Rank 1
answered on 15 May 2010, 02:44 AM
Any idea on when/if you will be adding support for DOC, DOCX, ODT or PDF?
0
Mike
Telerik team
answered on 18 May 2010, 08:35 AM
Hello Glenn Morton,

The DOCX and PDF formats are with higher priority in our plans. Docs will most probably be supported in Q2 and PDF soon after that. For now we are concidering ODT and DOC  (WordML) formats for Q3 release.

Best wishes,
Mike
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Glenn Morton
Top achievements
Rank 1
answered on 18 May 2010, 09:58 AM
Thats great to hear :)
0
Nikhil Thaker
Top achievements
Rank 1
answered on 30 Jul 2010, 06:33 AM
Hi,

Please let me know if HTML format is supported in RichTextBox now..?

thanks..

0
Ivailo Karamanolev
Telerik team
answered on 02 Aug 2010, 05:09 PM
Hello Nikhil Thaker,

Yes, HTML export and import is supported by RadRichTextBox. To access it, you'll either have to use RadRichTextBoxRibbonUI, which provides Save/Load functionality out-of-the-box or use HtmlFormatProvider class found in the assembly Telerik.Windows.Documents.FormatProviders.Html. Let us now if you need any further assistance.

Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
lori guymon
Top achievements
Rank 1
answered on 06 Aug 2010, 03:35 PM
Are there any sample applications that demonstrate how to do this (export in HTML format and bind to a database field) as I haven't been able to find any??
Thanks
0
Charles Bates
Top achievements
Rank 1
answered on 09 Aug 2010, 12:33 PM
Hello,
We have many user-editable objects in our application.  We need to serialize/de-serialize them frequently, as well as compare the RadRichTextBox's content with the ViewModel's representation.
What is the most-straightforward way to do that?  It seems rather cumbersome to have to continually go through all the steps required to use the HtmlFormatProvider.

Thanks for any information, and perhaps a sample...
C. Bates
0
Ivailo Karamanolev
Telerik team
answered on 09 Aug 2010, 05:50 PM
Hello C. Bates

Concerning the data binding, for SP1, which is coming this week, we have developed some supplementary classes that will allow you to bind the HTML, XAML or Text of a RadRichTextBox's document to a database field (or anything bindable in that sense). All this can happen directly in XAML, or in code behind.
In Q2 you had to do the exporting yourself using HtmlFormatProvider and SP1 is to amend that. As it's coming in the next few days, we hope that's not going to reflect badly on your schedule.

And regarding user-editable objects - currently, you can insert any control using InlineUIContainer, unfortunately, the serialization for this doesn't work. As a workaround you can serialize and reinsert the elements as you save the document. A fix for this will be available for Q3 and users will be able to provide their own serialization logic.

Please let us know if you need any further assistance.

Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Travis
Top achievements
Rank 1
answered on 24 Aug 2010, 07:35 PM
So... Are there samples or demos of how to use RichTextBox now with the HTML format?
0
Ivailo Karamanolev
Telerik team
answered on 25 Aug 2010, 08:16 AM
Hello Travis,

Here's the newest demo showing how to use DataProviders with RadRichTextBox:
http://demos.telerik.com/silverlight/#RichTextBox/Binding

And here - the help article that will give you some insight into the methodologies:
http://www.telerik.com/help/silverlight/radrichtextbox-how-to-binding-to-data-providers.html

Here's a small snippet that contains two methods: one that takes a HTML string and returns a document (which you can later assign to RadRichTextBox) and one that takes a RadDocument and returns an HTML string:
RadDocument FromHtml(string html) {
    return new HtmlFormatProvider().Import(html);
}
string ToHtml(RadDocument document) {
    return new HtmlFormatProvider().Export(document);
}
It's up to you to choose one from the options: either use HtmlDataProvider to bind the HTML text directly to something else, or manually use HtmlFormatProvider from code-behind.
I hope this helps.

Kind regards,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bhushan
Top achievements
Rank 1
answered on 01 Sep 2010, 03:11 PM

Hi,

Can anyone help me regarding converting the inserted custom controls in to the rich textbox in to HTML.
And provide me if you have any source code.

Thanks,
Bhushan
0
Boby
Telerik team
answered on 03 Sep 2010, 02:41 PM
Hi Bhushan,
Please refer to the answer in this thread.

Greetings,
Boby
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mircea
Top achievements
Rank 1
answered on 26 Nov 2010, 04:33 PM
Hello,

RTF format is supported now by the RadRichTextBox?
If not, it will be available soon?

Thanks
0
Iva Toteva
Telerik team
answered on 26 Nov 2010, 05:42 PM
Hello Mircea,

RTF support is not supported for now. It has been scheduled for Q1 2011, which is due around April next year. You can find information on the currently supported file formats and examples on their usage in this help article.
If you have other questions, do not hesitate to contact us again.

Sincerely yours,

Iva
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Angeli
Top achievements
Rank 1
answered on 13 May 2011, 09:30 AM
Hi, Ivailo.

I would like to ask about this line of code here: [one that takes a HTML string and returns a document (which you can later assign to RadRichTextBox)]

RadDocument FromHtml(string html) {
    return new HtmlFormatProvider().Import(html);
}

does is have any restrictions on the string literals?
i tried to set the string  to the HTML file I exported coming from the RadGridView but nothing happens.
<table style="border-collapse:collapse" border="1">
<tr>
<td style="width:45">ID</td><td style="width:113">CategoryName</td><td style="width:212">Description</td><td style="width:79">Quantity</td><td style="width:58">Price</td><td style="width:273">AdditionalDetails</td></tr>
<tr>
<td>1</td><td>Kayaks</td><td>Traditionally used by hunters</td><td>5</td><td>1999.99</td><td>asdfghjklasdfghjkl;asdfghjkl;asdfghjkl;sdfghjkl;</td></tr>
<tr>
<td>2</td><td>Canoes</td><td>Small, narrow, human-powered boat</td><td>6</td><td>1999.99</td><td>asdfghjklasdfghjkl;asdfghjkl;asdfghjkl;sdfghjkl;</td></tr>
<tr>
<td>3</td><td>Dinghies</td><td>Small boats, 2-3 meters long</td><td>7</td><td>1999.99</td><td>asdfghjklasdfghjkl;asdfghjkl;asdfghjkl;sdfghjkl;</td></tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td></tr>
</table>

is there a solution to this?
0
Iva Toteva
Telerik team
answered on 13 May 2011, 12:11 PM
Hello Angeli,

The problem with the file is that the styles of the table cells specify widths without a measuring unit (which is invalid according to the CSS specification). If you add a measuring unit, e.g. 

<td style="width:45px">
the HTML will be properly imported.
We have adjusted our import, so that if no measurement unit is appointed, pixels are inferred, although the CSS standard states that a unit must be present.

Greetings,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Angeli
Top achievements
Rank 1
answered on 13 May 2011, 04:38 PM
oh now i see. thanks for the help!
0
Олег
Top achievements
Rank 1
answered on 09 Dec 2014, 09:47 AM
Hello!
I wanted to exclude all attributes when serialize td like this: <td>... and so on.
Its explained there: http://www.telerik.com/help/wpf/radrichtextbox-features-import-export-settings.html
I added to ignores these properties:

htmlExportSettings.PropertiesToIgnore["td"].Add("border-top");
htmlExportSettings.PropertiesToIgnore["td"].Add("border-bottom");
htmlExportSettings.PropertiesToIgnore["td"].Add("border-left");
htmlExportSettings.PropertiesToIgnore["td"].Add("border-right");
htmlExportSettings.PropertiesToIgnore["td"].Add("padding");
htmlExportSettings.PropertiesToIgnore["td"].Add("vertical-align");
htmlExportSettings.PropertiesToIgnore["td"].Add("align");

And result is:
<td align="left" valign="top">...  =>  <td>...

What's wrong?


0
Mihail
Telerik team
answered on 11 Dec 2014, 04:12 PM
Hello Oleg,

Thank you for contacting us.

I can confirm that there is a problem with ignoring the export of attributes for table cell in html format.
I have opened bug report item in our feedback portal where you could track the overall progress of the issue.

Please excuse us for the inconvenience.

On a side note we made some improvements in our help documentation. If you are interested you can check it at RadRichTextBox help for Silverlight or WPF.

Regards,
Mihail
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RichTextBox
Asked by
bob thomash
Top achievements
Rank 1
Answers by
Mike
Telerik team
Glenn Morton
Top achievements
Rank 1
Nikhil Thaker
Top achievements
Rank 1
Ivailo Karamanolev
Telerik team
lori guymon
Top achievements
Rank 1
Charles Bates
Top achievements
Rank 1
Travis
Top achievements
Rank 1
Bhushan
Top achievements
Rank 1
Boby
Telerik team
Mircea
Top achievements
Rank 1
Iva Toteva
Telerik team
Angeli
Top achievements
Rank 1
Олег
Top achievements
Rank 1
Mihail
Telerik team
Share this question
or