7

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

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392

2 Answers2

20

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

Chris Latta
  • 20,316
  • 4
  • 62
  • 70
  • i use `visual studio 2008` and i can't find those steps :( – Anyname Donotcare Jun 09 '13 at 14:00
  • I use VS2008 as well. Click the field so that `` is highlighted, then right-click it and choose `Placeholder Properties...` from the pop-up menu – Chris Latta Jun 10 '13 at 05:10
  • Could u provide some screen shots cuz i didn't find any of these steps !! i have update my question with a screen shot of my `Right click Menu` – Anyname Donotcare Jun 10 '13 at 07:36
  • You don't have the field highlighted so you won't get that option. Left click the cell first so that the contents of the cell are highlighted. Then right-click the highlighted text. – Chris Latta Jun 10 '13 at 09:17
  • 2
    @just_name check the updated answer, I added some ScreenShots. – eestein Jun 11 '13 at 14:02
  • @g.Raam : I don't have this screen !! i do the steps but in vain .I update my question with a new screen shots . – Anyname Donotcare Jun 11 '13 at 14:20
  • If you delete what's in the field and then right-click, do you get a menu option "Create Placeholder"? If so, do that and set your expression from the popup menu and switch the markup type to HTML. – Shane LeBlanc Jun 11 '13 at 15:39
  • @just_name it seems to me you are having a different problem. What is the type of that row? If you just add the field like this: `[YourDatasetFieldName]` does it work? – eestein Jun 11 '13 at 16:07
  • @g.Raam Thanks for adding the screenshots – Chris Latta Jun 11 '13 at 23:52
  • @g.Raam :it's an rdlc report , and i use table then in a specific cell i use right click ,then select expression and after that i select field from my dataset like `=Field.!other_desc.Value` – Anyname Donotcare Jun 12 '13 at 08:00
  • @just_name Did you try using `[other_desc]`? If you are using SSRS 2008, a tablix with a dataset correctly defined, using `[other_desc]` instead of `=Fields!other_desc.Value` should work. I would start there. With the expression selected, what box shows up when you select `Properties` in your screen shot? – eestein Jun 12 '13 at 11:05
  • @g.Raam : I don't use `SSRS` ,i use report viewer ,.rdlc report in viual studio 2008 – Anyname Donotcare Jun 13 '13 at 13:22
  • 2
    @just_name Ok, I should've started with that then. What you must do is create a `Text Box` (Insert -> Text box), then insert your field there and you'll be able to see `Placeholder Properties` when you right-click the selected content. Hope it works – eestein Jun 13 '13 at 14:20
  • @g.Raam: should i insert the textbox in the table cell ? – Anyname Donotcare Jun 13 '13 at 14:21
  • @g.Raam: I try to that but the same problem no `Placeholder Properties` at all.Could u add a report item to a project in visual studio 2008 and try it please .. – Anyname Donotcare Jun 13 '13 at 15:50
  • 1
    @just_name Ok, I will. In 6h I will be able to do so and will get back to you with the results. – eestein Jun 14 '13 at 10:43
  • 1
    @just_name do you see Text Properties? Anything like this? – eestein Jun 14 '13 at 16:39
  • I'm sorry the delay, I was out this weekend. Just help me out here, do you know how to create a placeholder? When you click textbox properties, what box shows up? – eestein Jun 17 '13 at 13:13
  • 1
    It appears Visual Studio doesn't support HTML markup for RDLC reports until VS2010. Answer updated. – Chris Latta Jun 18 '13 at 00:28
  • 1
    To see it easily, delete the content of the textbox. Then when the text cursor is in the textbox, right click and you'll see "Create Placeholder". You need to have the actual element in the textbox highlighted to see it - not the textbox. – Adam Dec 05 '16 at 21:33
  • @Adam thank you, that was the info I needed. I think that info is probably worth adding as a supplementary answer considering the potential for comments to be deleted? – tomRedox Mar 04 '18 at 19:48
4
  1. Double click at field area
  2. At Placeholder properties choose General > HTML - Interpret HTML tags as styles

field area

Wildan Muhlis
  • 1,553
  • 2
  • 22
  • 43