January 16, 2008...10:09 am

Render HTML tags in DB in ActiveReport pdf or HTML

Jump to Comments

I had to tackle showing actual HTML formatting that was stored in the DB by our company’s own texteditor which had the basic formatting like bold, italics, font colout etc, and digging around the active reports forum basically just told me I needed to version 4.0+ for it to be automatically rendered in RichTextBox.

The solution that arose from asking around was that in the Detail_Format() section in the code behind of the report put this line:
ctl.cComments.Html = fld.Comments.ToString()

Where cComments is a RichTextBox and Comments is the name of the datafield

and that worked beautifully! Except it would not render in Arial, the default font, even though I formatted the richtextbox to be so. Thinking of many complicated ways to do this, the solution was as simple as:

ctl.cComments.Html = “<font face=Arial>”+fld.Comments.ToString()+”</font>”

This is probably not a fix and more of a quickfix or hack, but works as well otherwise.

1 Comment

  • Try to separate content and formatting by using CSS.

    For large amounts of content, the formatting code gets in the way and makes it difficult to reformat the content should the need arise.


Leave a Reply