IF fields
Evaluate conditional text
Merge the product data to evaluate the template's IF fields. Each field chooses its true or false text from the associated data value.
Template logicResolve true and false text
The business wording stays beside the surrounding document content.
IF fieldExpressionIn template
ValuesFrom JSON
EvaluationDuring merge
ResultSelected text
Template structureUnderstand the current template
Explore its merge fields, repeating blocks, and nested structure in an interactive template map.
Inspector
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Put business wording in the template
An IF field compares the value of a named merge field with another expression. The template stores both possible results and inserts the appropriate text during the merge.
This keeps conditional wording close to the surrounding document instead of assembling sentences in controller code.
API used
MailMerge.MergeJsonData
Key members
MailMerge evaluates the IF field expressions stored in the template while resolving their referenced values from JSON.
using var textControl = new ServerTextControl();
textControl.Create();
using var mailMerge = new MailMerge
{
TextComponent = textControl,
RemoveEmptyBlocks = true
};
mailMerge.LoadTemplate(templatePath, FileFormat.InternalUnicodeFormat);
mailMerge.MergeJsonData(File.ReadAllText(dataPath));
mailMerge.SaveDocumentToMemory(
out byte[] document,
BinaryStreamType.InternalUnicodeFormat,
new SaveSettings());
How it works
MailMerge resolves the referenced field value, performs the comparison encoded in each IF field, and replaces the field with its true or false result in the output document.
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0