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

Inserting HTML content

1 Answer 80 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 15 Nov 2012, 10:06 PM
I have a collection of question and responses.  When reading the responses back, I like to retain the HTML it's in.

I thought I could add it to SPAN or PARAGRAPH, but it only sees it as a string.

How would I insert something like this into a RadDocument?
<p style="margin-top: 0px;margin-bottom: 12px;line-height: 1.15;"><span style="font-family: 'Times New Roman';font-size: 16px;">Hello World!</span></p>

I would like to have as much control over the content as I could.  Again, I was creating tables and cells and thought I could insert it there.  If there's a better method, I'd like to know.

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 20 Nov 2012, 02:24 PM
Hi Mike,
I am having a hard time understanding your question, so please excuse me if I am wrong in my assumptions.
In order to load HTML document in RadRichTextBox, you can use the HtmlFormatProvider. You can find information regarding the format providers and how to use them here. There are also different export/import settings you can use to control the export/import process to some degree, but be aware that RadRichTextBox is not designed to be an HTML editor, and the purpose of the export is to preserve as much of the document properties as possible, rather than exporting HTML similar to the imported HTML.

If you wish to show the actual HTML code in the editor, you can try adding it to the document following the elements hierarchy as the text of a Span element. Here you can find an example of a document created at run-time. Please be alarmed that you would have to escape the code using the standard escape sequences as Span's Text property is of type string.
However, if neither of those scenarios fits your requirements, please send us some additional details on the matter, so we can be of more help.
 

Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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