Embedded Expression within HtmlTextBox

3 posts, 1 answers
  1. Ali Mohamad
    Ali Mohamad avatar
    15 posts
    Member since:
    Oct 2009

    Posted 15 Dec 2014 Link to this post

    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. Answer
    Nasko
    Admin
    Nasko avatar
    1050 posts

    Posted 18 Dec 2014 Link to this post

    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.

     
  3. Ali Mohamad
    Ali Mohamad avatar
    15 posts
    Member since:
    Oct 2009

    Posted 23 Dec 2014 in reply to Nasko Link to this post

    Thank you Nasko, that worked as described :)
Back to Top