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

Problem with HtmlTextBox error in Report

6 Answers 284 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manuel
Top achievements
Rank 1
Manuel asked on 20 Dec 2011, 03:15 PM
Hi there,

In my database I have a field that have html code in a string, like this example:

<!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">
.p_CC664AAA { margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_E6FD2046 { font-family: 'Verdana';font-style: Normal;font-weight: normal;font-size: 16px;color: #000000; }
</style></head><body><p class="p_CC664AAA"><span class="s_E6FD2046">assunto 1</span></p></body></html>


So when I try show this in a report using HtmlTextBox control occures one error. Please see the picture.

I read somewhere in this forum, that this happens because the control don´t support chars like < &  or > .. This is true?

How workaround?

Thanks

6 Answers, 1 is accepted

Sort by
0
Manuel
Top achievements
Rank 1
answered on 26 Dec 2011, 04:42 PM
Hello? Any help here please...this is urgent!
0
Chavdar
Telerik team
answered on 26 Dec 2011, 05:07 PM
Hello Manual,

Please, take a look at the documentation for the HtmlTextBox item. It renders only specific HTML tags and not entire html pages as it is in your case.

As a workaround you can use the WebBrowser control to create a bitmap with the rendered html page and then pass the image to a PictureBox item to display it in a report. You may find useful the Get Bitmap of Web Browser Control in C# discussion about how to achieve this.

Hope this helps.

All the best,
Chavdar
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manuel
Top achievements
Rank 1
answered on 26 Dec 2011, 06:48 PM
Hi, OK, there is some way to get the content of "=Fields.CONTEUDO" for example?

Thanks,
0
Accepted
Chavdar
Telerik team
answered on 26 Dec 2011, 08:21 PM
Hello,

You can use a user function and pass the value of the field as an argument. Consider the following code snippet:

public Report()
{
    /// <summary>
    /// Required for telerik Reporting designer support
    /// </summary>
    InitializeComponent();
 
    //
    // TODO: Add any constructor code after InitializeComponent call
    //
 
 
    this.pictureBox1.Value = "=GetImage(Fields.CONTEUDO)";
}
 
public static Image GetImage(string html)
{
    return new Bitmap(100, 100);
}

All the best,
Chavdar
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Manuel
Top achievements
Rank 1
answered on 27 Dec 2011, 12:42 PM
Hi,

Thanks for the tip. Works good.

Another question please. There is some style that we can apply to report, something like css but for reports.

Thanks
0
Elian
Telerik team
answered on 27 Dec 2011, 05:04 PM
Hi,

Yes, Styles allow you to change the layout in a way similar to CSS.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Manuel
Top achievements
Rank 1
Answers by
Manuel
Top achievements
Rank 1
Chavdar
Telerik team
Elian
Telerik team
Share this question
or