Anyname Donotcare
Anyname Donotcare

Reputation: 11403

How to render the formated text in the report.rdlc (with its format)

I store my data in formatted way in my db , I want some way to render the text with its format in my report.rdlc i use visual studio 2008 How to do this :


For example :

if my text like this :

<p>text</p>

It appears the same with tags in my report text box !!. instead of rendering as a paragraph.


when i bind like this :

= Fields.subject

How to fix this problem ?


enter image description here

Upvotes: 7

Views: 35135

Answers (2)

Wildan Muhlis
Wildan Muhlis

Reputation: 1603

  1. Double click at field area
  2. At Placeholder properties choose General > HTML - Interpret HTML tags as styles

field area

Upvotes: 5

Chris Latta
Chris Latta

Reputation: 20560

Edit

After researching this problem a bit more it appears Visual Studio doesn't support Markup as HTML for rdlc reports until Visual Studio 2010. So if upgrading is an option, then you can do what you want.

Otherwise you could always just strip out the HTML tags like so:

On the Report menu, click Report Properties... and select the Code tab. Enter the following code:

Function StripHTMLTags(ByVal text as String) AS String
  Return System.Text.RegularExpressions.Regex.Replace(text, "<(.|\n)*?>", "")
End Function

Now in your cell use the following expression:

=Code.StripHTMLTags(Fields!MyField.Value)

Original answer follows:

Leaving aside that you should separate data from presentation, you can render using HTML tags in Reporting Services, its just not very intuitive to find:

  1. Left click the field you want to display so that the <Expr> tag is highlighted
  2. Right click the highlighted <Expr> tag and choose Placeholder Properties...
  3. On the General tab, select the HTML- Interpret HTML tags as style radio button

Only a limited number of tags are supported however. This article on MSDN tells your more.

Screenshots:

enter image description here

enter image description here

Upvotes: 21

Related Questions