Inserting HTML content

2 posts, 1 answers
  1. Mike
    Mike avatar
    8 posts
    Member since:
    Dec 2011

    Posted 15 Nov 2012 Link to this post

    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!
  2. Answer
    Petya avatar
    990 posts

    Posted 20 Nov 2012 Link to this post

    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,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top