The Mail ╰ TX Text Control .NET Server for ASP.NET
╰ DocumentServer Namespace
╰ MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services. engine allows the combination of merge and form fields to be merged with data from various data sources such as JSON or IEnumerable objects. Probably the most common automation element are merge fields. These are placeholders in templates with specific names that are populated with data from various data sources. Form fields can be pre-populated using the same engine to prepare forms for users to complete. Those fields can be pre-populated or flattened.
Consider the following Patient Medical History form that is typically completed by patients:
JSON Data
The following JSON data is used to merge the above template:

Merging Merge Fields
To increase the patient experience, to accelerate the process and to decrease errors, parts of the document can be pre-populated. In the header, the doctor's name and the current date is known and can be merged into a merge field:
Pre-Populating Form Fields
The second part consists of form fields where some data is already known and can be pre-populated:
The following code is used to merge the JSON data into the template. Pay attention to the Form ╰ TX Text Control .NET Server for ASP.NET
╰ DocumentServer Namespace
╰ MailMerge Class
╰ FormFieldMergeType Property
Specifies in which manner form fields are treated during the merge process. property being set to Preselect.

The form fields are pre-populated, but the patient is still able to modify the form fields or to make further selections.
Flattening Form Fields
If the FormFieldMergeType property is set to Replace, the form fields are flattened and cannot be modified after the merge process:

Conditional Merge Blocks
The third part of the template is a conditional merge section in form of a merge block. Merge blocks are removed by default when the associated data is not present in the given data source. The following screenshot shows the template loaded in the TX Text Control document editor and shows the Additional Notes section inserted as a merge block.
In case the element AdditionalNotes exists in the given JSON data (like in the above sample), the complete merge block is rendered and executed. If the element AdditionalNotes is removed from the data, the complete block is not rendered.
Download Template
You can download the demo template and JSON data for your own tests.