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:

Loading...

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

Loading...

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.
method.

Loading...

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:

Loading...

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.

Loading...

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.