I have a report that gives the nutrient breakdown of a feed ingredient. Sometimes the users in the lab will name the ingredient such that it references other work they are performing which typically results in the use of special characters. When they use "{}" the report viewer throws an exception.
I know that there is a workaround in C# to resolve these conflicts but how do I get around this in the Telerik Reporting system (short of scrubbing the data to remove the offending character?) The Value assignment in the example code causes this issue.
Example code:
<TextBox Width="1.78in"
Height="0.17in"
Left="0in"
Top="1.96in"
Value="{35 DM NDF M}"
Name="lblDietSummary_Title_0">
<Style Visible="True"
Color="Black"
TextAlign="Left"
VerticalAlign="Middle">
<Font Name="Arial"
Size="9pt"
Bold="True" />
</Style>
</TextBox>
7 Answers, 1 is accepted

For further clarification, this report item is generated in code:
Text box definition & value assignment:
tbTitle.Name = "lblDietSummary_Title_0);
tbTitle.Value = SpecialCharacterScrubber(myDietSummary["Ingredient"].ToString());
Attempt to clean up the string value:
private string SpecialCharacterScrubber(string checkField)
{
checkField = checkField.Replace("{", "{");
checkField = checkField.Replace("}", "}");
return checkField;
}
which resulted in "{35 DM NDF M}" being printed on the report. Not the desired result.
As curly brackets are used by the engine to identify embedded expressions they should be escaped with double brackets: {{ or }}.
For example, textBox1.Value = "{{35 DM NDF M}}".
Regards,
Katia
Telerik


Hey Tom. You might want to try an HTML textbox and escape the characters. I just created an HTML textbox with a square.
<span style='color: green;'>■</span> Category

I just created a method to resolve it.
private string SpecialCharacterScrubber(string checkField)
{
checkField = checkField.Replace("{", "{{");
checkField = checkField.Replace("}", "}}");
return checkField;
}
Thanks for the suggestion just the same.

I know how to escape curly brackets - { } :
Embedded Expressions
https://docs.telerik.com/reporting/expressions-embedded
But how to escape square brackets and leading equal sign for TextBox.Value ?
MyTextBox.Value = "[=abdominal fullness ...]";
*Plain text "[=abdominal fullness ...]".
Error message :
Value expression [=abdominal fullness ...] is not valid:
Missing operator before 'fullness' operand.
ExceptionType: System.Exception
at Telerik.Reporting.Processing.ExpressionExtractor.ExtractEmbeddedExp(String expression, String sourceName, String property)
at Telerik.Reporting.Processing.ExpressionExtractor.VisitTextBox(TextBox item)
at Telerik.Reporting.TextBox.Accept(ReportItemVisitor visitor)
at Telerik.Reporting.Processing.ExpressionExtractor.Visit(ReportItemBase item)
at Telerik.Reporting.ReportItemVisitor.VisitExtension(ReportItemBase item)
at Telerik.Reporting.Processing.ExpressionExtractor.Visit(ReportItemBase item)
at Telerik.Reporting.ReportItemVisitor.VisitExtension(ReportItemBase item)
at Telerik.Reporting.Processing.ExpressionExtractor.Visit(ReportItemBase item)
at Telerik.Reporting.Processing.ExpressionExtractor.VisitAllExpressions(ReportItemBase item)
Best regards
Chris
Hi Chris,
I have tested using [=abdominal fullness ...] as a Value of a textbox, however, I am afraid I was not able to reproduce the problem. Please, check the attached report.
Basically, when the value starts with =, it will be treated as an expression. To escape the equal sign in the Standalone designer, you can use the expression below:
= ("=AAAA")
Can you please send us a sample report that reproduces the problem, so I can test it locally? I will be looking forward to receiving an update from you.
Regards,
Neli
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.