With the release of TX Text Control X13, we released an MVC version of TXTextControl.Web that is available through NuGet.

This sample project shows how to load and save documents using controller methods and Javascript. The view contains the TXTextControl.Web HtmlHelper and two buttons to save and to load the document.

Loading...

The Javascript function SaveToController uses the method saveDocument to save the document client-side in the internal Unicode format. Then, the jQuery AJAX method calls the controller method SaveTemplate by sending a JSON string that contains the document name and the saved document.

Loading...

The controller HttpPost method accepts the JSON string in form of a model in the parameter. The document is converted to a byte[] array and loaded into a temporary ServerTextControl instance. Finally, the document is saved server-side using the Save method of the ServerTextControl object.

Loading...

The model DocumentViewModel is shown in the code below:

Loading...

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

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on GitHub.com/TextControl.

Please fork and contribute.

Requirements for This Sample

  • Visual Studio 2012 or better
  • TX Text Control .NET Server for ASP.NET (trial sufficient)