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

Rich TextBox Data

3 Answers 56 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Hemanth
Top achievements
Rank 1
Hemanth asked on 05 Dec 2012, 01:33 PM


Hi,

I have an application in which I am using RadRichTextBox, everything works fine but I am trying to convert the text entered in this textbox to HTML format. For this I am using HtmlFormatProvider. But the output is not like I want it to be.

for eg. Suppose I enter text "hello" and convert it, it gives me the following output.

"<!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\">\r\n.s_D8D99854 { font-family: 'Verdana';font-style: Normal; } \r\n</style></head><body><p ><span class=\"s_D8D99854\">&nbsp;hello</span></p></body></html>"



but i dont want all these tags.So  i did this below code


             HtmlExportSettings exportSettings = new HtmlExportSettings();
            exportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
            exportSettings.StyleExportMode = StylesExportMode.Inline;
            HtmlFormatProvider formatProvider = new HtmlFormatProvider();
            formatProvider.ExportSettings = exportSettings;
            formatProvider.Export(radRichTextBox.Document);


exportSettings.StyleExportMode = StylesExportMode.Inline;

This i m getting error

Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlExportSettings' does not contain a definition for 'DocumentExportLevel' and no extension method 'DocumentExportLevel' accepting a first argument of type 'Telerik.Windows.Documents.FormatProviders.Html.Export.HtmlExportSettings' could be found (are you missing a using directive or an assembly reference?


Can some pls help me....


3 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 07 Dec 2012, 03:31 PM
Hello Hemanth,

The property in question seems to be misspelled. It is actually called StylesExportMode and if you change it everything should work as expected.You can also refer to this help article where the export settings are explained in further detail. 

I hope this is helpful!
 
All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hemanth
Top achievements
Rank 1
answered on 08 Dec 2012, 12:24 PM
thanks Petya for reply,

You are right...

can u pls tel how i get entered text in radrichtextbox for ex: "Hello"
and store that in string

0
Petya
Telerik team
answered on 12 Dec 2012, 04:49 PM
Hello Hemanth,
If you wish to export your document and store it in a variable defined in code, you can do that using one of our format providers. If you simply wish to save the contents of the document as plain text, you can use the TxtFormatProvider. On the other hand, if you need the content of the document as rich text and do not have any requirements for a specific format, we usually recommend using the XamlFormatProvider as it is native for the document's structure. You can find code samples in the help article I referenced.
If, however, you wish to adopt a data-bound scenario, you can refer to our data providers. They basically encapsulate the format providers and allow usage in XAML.
 
Regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Hemanth
Top achievements
Rank 1
Answers by
Petya
Telerik team
Hemanth
Top achievements
Rank 1
Share this question
or