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

read html from editor

2 Answers 110 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Roman
Top achievements
Rank 1
Iron
Roman asked on 18 Nov 2019, 03:36 PM

Hi there,

I'm using the RadRichTextEditor the first time and I'm wondering if it is somehow possible to get only the HTML out of the editor. I've thought about something like:

1.string htmlText = txtText.Text; // while txtText is my RadRichTextEditor


But this returns me the plain text, without any html tags. I've seen I can export and import it using a HtmlFormatProvider. This worked great, but it is not exactly the thing I want, since it returns the whole HTML document instead of only the html I have in my text editor.

1.HtmlFormatProvider prov = new HtmlFormatProvider();
2.string htmlText = prov.Export(txtText.Document);

The output I wish would be something like this:

1.string htmlText = "This is a <b>bold</b> text. Great, isn't it?"

Regards,
Roman

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 19 Nov 2019, 02:12 PM

Hi Roman, 

You can configure this in the export settings. For example, you can set the following properties: 

HtmlFormatProvider provider = new HtmlFormatProvider();
provider.ExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
provider.ExportSettings.StylesExportMode = StylesExportMode.Inline;
provider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;

string result = provider.Export(radRichTextEditor1.Document);

Detailed information is available here: Settings | RadRichTextEditor.

I hope this helps. Please let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Roman
Top achievements
Rank 1
Iron
answered on 19 Nov 2019, 03:42 PM
Hi Dimitar,

Great! This is exactly what I need. Thanks for the answer.

Regards,
Roman
Tags
RichTextEditor
Asked by
Roman
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Roman
Top achievements
Rank 1
Iron
Share this question
or