With the latest multi-platform release of the NuGet package, TXTextControl.Web TX Text Control .NET Server for ASP.NET
Web.MVC Namespace
TXTextControl.Web.MVC Namespace
can now be used in ASP.NET Core Web Applications. This article shows how to use a model as the data excerpt file for the document editor and how to merge the actual data into the created template in an HTTP Post method in the MVC controller.

Loading Data from Model

Consider the following, very simple model Customer.cs:

public class Customer
public string Name { get; set; }
public string Firstname { get; set; }
public string Company { get; set; }
view raw test.cs hosted with ❤ by GitHub

In the controller, a dummy data object is created and stored in a list to be used as the view model.

public IActionResult Index()
List<Customer> lDummyData = new List<Customer>();
lDummyData.Add(new Customer()
Company = "Text Control, LLC",
Firstname = "Tim",
Name = "Typer"
return View(lDummyData);
view raw controller.cs hosted with ❤ by GitHub

In the view itself, the excerpt file is loaded from a model using the LoadDataFromModel TX Text Control .NET Server for ASP.NET
Web.MVC Namespace
TextControl Class
LoadDataFromModel Method
Loads a collection implementing interface System.Collections.IEnumerable as a data source.

@using TXTextControl.Web
@using TXTextControl.Web.MVC
@model List<TXCoreBackend.Models.Customer>
<div class="row">
<div class="col-lg-12 editor">
@Html.TXTextControl().TextControl(settings =>
settings.Dock = DockStyle.Fill;
view raw test.cshtml hosted with ❤ by GitHub

Based on the data in this model, the reporting tab merge field drop-downs are filled with available merge field names:

Data model in TX Text Control

Server-Side Merge

On clicking the button Merge Document Server-Side, the document is saved using saveDocument TX Text Control .NET Server for ASP.NET
JavaScript API
TXTextControl Object
saveDocument Method
Saves the current document in a certain format and sends the result back asynchronously by calling a given callback function.
, encapsulated in an object and posted to the HTTP Post controller method MergeDocument:

function mergeDocument() {
$("#infobox").text("Merging document...");
TXTextControl.StreamType.InternalUnicodeFormat, function (e) {
type: "POST",
url: "/Home/MergeDocument",
contentType: "application/json",
data: JSON.stringify({
Document: e.data
success: function (content) {
function () {
$("#infobox").text("Merged and loaded");
view raw angular.js hosted with ❤ by GitHub

In the controller method, the template is loaded into a ServerTextControl TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications.
instance, merged with data using MailMerge 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.
, saved back and returned to the client.

public string MergeDocument([FromBody] MergeDocument MergeDocument)
// create some merge data rows
List<Customer> lActualData = new List<Customer>() {
new Customer()
Company = "Text Control, LLC",
Firstname = "Tim",
Name = "Typer"
new Customer()
Company = "Text Control GmbH",
Firstname = "Bernie",
Name = "Bold"
byte[] baResults;
// create a new ServerTextControl instance to connect to MailMerge
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
// load the template
// connect MailMerge
MailMerge mm = new MailMerge();
mm.TextComponent = tx;
// merge data into template
// save results
tx.Save(out baResults, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
return Convert.ToBase64String(baResults);
view raw Customer.cs hosted with ❤ by GitHub

Loading the Results

After a successful merge process, the returned document is loaded into the document editor:

Data model in TX Text Control

TX Text Control .NET Server for ASP.NET can be used to create ASP.NET Core Web Applications including the fully-featured document editor and the backend functionality including MailMerge capabilities.