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

Embedded Expression within HtmlTextBox

2 Answers 458 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ali Mohamad
Top achievements
Rank 1
Ali Mohamad asked on 16 Dec 2014, 01:08 AM
Hi, I am running into a problem with the latest version of the reporting engine (8.2.14.1204).
I have a HtmlTextBox that contains some html (example below) and I want a currency value to be displayed properly formatted, e.g. $100.00. The problem is that I can't make the expression work no matter how I enter it... Assume that the following fields exist in the sql dataset:

Fields.owing    money not null
Fields.prevbalance    money not null

So this is what I want the text to show when the report is run,
Your current owing amount is $115.24 and the previous balance is $75.22. Please....

this is what I have tried in the Html source...
Your current owing amount is {Format("{0:C2}", Fields.owing)} and the previous balance is {Format("{0:C2}", Fields.prevbalance)}. Please....

This yields a error message when the report is run:
textBox1.Value expression [Your current owing amount is {Format("{0:C2}", Fields.owing)} and the previous balance is {Format("{0:C2}", Fields.prevbalance)}. Please....] is not valid:
Error evaluating embedded expression : Unexpected token inside an expression at index 39

What is the correct way to embed field values in text and properly format them? I cannot really split the text into separate textboxes, there is a lot of text that includes legal verbiage with field data embedded in it...

Thank you
Ali M.

2 Answers, 1 is accepted

Sort by
0
Accepted
Nasko
Telerik team
answered on 18 Dec 2014, 01:30 PM
Hello Ali Mohamad,

Expressions are embedded in a string literal by surrounding them with curly brackets {}. If used in a string literal, curly brackets - { } should be escaped with double brackets like this: {{ or }}. For more information and examples, please refer to the Embedded Expressions help article.

Your expression should be modified like this:

Your current owing amount is {Format("{{0:C2}}", Fields.owing)} and the previous balance is {Format("{{0:C2}}", Fields.prevbalance)}. Please....

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ali Mohamad
Top achievements
Rank 1
answered on 23 Dec 2014, 10:00 PM
Thank you Nasko, that worked as described :)
Tags
General Discussions
Asked by
Ali Mohamad
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Ali Mohamad
Top achievements
Rank 1
Share this question
or