The MVC version of TX Text Control provides a JavaScript API to load and save documents locally:

These client-side methods are very useful when managing your data including documents client-side. In case you would like to store your documents server-side, you would need to save it locally in order to send it to the server again. For a saving process, the document is being sent twice using HTTP.

Because the document is already server-side (it gets synchronized with the document synchronization service), you can use a little trick to save the document directly server-side without the overhead of sending it back and forth.

The following code stores Text Control settings including the ConnectionID that can be used server-side to connect to the proper instance:

Loading...

The following function calls a Web API endpoint with the given ConnectionID:

Loading...

In the controller code, the ConnectionID is used to retrieve the associated instance of the WebSocketHandler:

Loading...

Then the LoadText method can be used to load the document directly server-side which updates the view in the HTML5 canvas automatically.

The following diagram shows the workflow for this scenario:

Loading workflow in MVC

You can test this on your own by downloading the sample project from our GitHub repository.

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 2017 or better
  • TX Text Control .NET Server for ASP.NET (trial sufficient)