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:


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:


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


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.