Ampersand breaks title formatting


https://www.nevron.com/Forum/Topic7693.aspx
Print Topic | Close Window

By Bob Smith - 11 Years Ago

Hey!

Not super high priority, but I discovered that when a block of text is dynamically added to a title (ex: =FIRST(Fields!Title) & "Chart") and it happens to contain an ampersand (& the title field loses all it's HTML formatting. All the raw tags are visible.

Any way to escape the ampersand or scrub for it?

By Nevron Support - 11 Years Ago

Hi Bob,
You probably mean that you lose the XML formatting. Can you please provide a more detailed example with the XML formatting?

By Bob Smith - 11 Years Ago

=Fields!Title & " Cost Projection <br/><u>Click to return to full company listing</u>"

Title fields:

1: Walmart

2: Ben & Jerry's

Title containing field 1 will work just fine - the formatted text will show:

"Walmart Cost Projection

Click to return to full company listing"

Title containing field 2 will be broken:

Ben & Jerry's Cost Projection <br/><u>Click to return to full company listing</u>

I believe this is due to the ampersand in ( & ) in the title field; it is appending the rest of the title as a string.

By Nevron Support - 11 Years Ago

Hi Bob,
The problem is because the & operator doesn’t support chaining.
You should use something like:
=JOIN(Fields!Title, "<br/>") + "<br />Cost Projection<br/><u>Click to return to full company listing</u>"
or
=JOIN(Fields!Title + "<br />Cost Projection<br/><u>Click to return to full company listing</u>", "<br/>")

Hopefully this helps.

 

By Bob Smith - 11 Years Ago

Turns out that the solution was to use the "REPLACE()" function:

=REPLACE(Fields!Title, "&", "&amp;") + "<br />Cost Projection<br/><u>Click to return to full company listing</u>"

This replaces the ampersand character with an escaped ampersand character code thereby eliminating the issue.

Thanks Nevron support!