The most typical application for the Web.TextControl is the creation of templates for the Text Control Reporting engine DocumentServer.MailMerge. The ribbon tab Reports is designed to insert merge fields and merge blocks compatible to the reporting classes of TX Text Control.

The drop-down buttons Select Master Table, Merge Field and Merge Block are pre-filled with items of a specific Database Excerpt XML file or a DataSet that can be loaded programmatically.

Typically, the template is merged server-side with a business object created from a class model. In this case, it makes sense to pre-fill the drop-down lists from a view model as well. The following simple model is used in this sample:

public class address
public string Name { get; set; }
public string Street { get; set; }
view raw file.cs hosted with ❤ by GitHub

Note the Serializable attribute in the class model. In the controller, the model object is created and typically filled with data from a database. After that, the object is serialized and stored in the ViewBag:

public ActionResult Index()
// create a new instance of the model
// fill the model from your data source here
address newAddress = new address()
Name = "Peter Jackson",
Street = "2332 Paul Jackson Dr"
// create a new XML document
XmlDocument xml = SerializeToXmlDocument(newAddress);
// fill the ViewBag and return the view
ViewBag.xmlDataSource = xml;
return View();
view raw HomeController.cs hosted with ❤ by GitHub

In the view, the LoadXMLDatabase method loads the stored XML document from the ViewBag:

@Html.TXTextControl().TextControl(settings =>
settings.Dock = DockStyle.Window;
view raw Index.cshtml hosted with ❤ by GitHub

The drop-down lists are now pre-populated with the available merge fields and merge blocks:

MVC: Loading a data source from a view model

Download the sample from GitHub and test it on your own.