Since TX Text Control .NET Server for ASP.NET 30.0 supports .NET 5 and .NET 6, the components can be used in Blazor Server Apps. This article shows how to save a document using the document editor and to modify the document server-side using the 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.
class.

Data Flow

The following dialog shows the data flow in this concept. The JavaScript API of TX Text Control is used to save the document which is transferred to .NET (the "server"). In .NET, the document is processed using an instance of ServerTextControl and is sent back to client-side by invoking a JavaScript function that loads the content back into the TX Text Control document editor.

TX Text Control in Blazor

Server-side, the document is loaded and modified by adding the text "This document has been modified by .NET" to the beginning of the document before it is loaded back into the editor.

TX Text Control in Blazor

The Required Code

The following code shows the editor page that consists of the document editor and a button:

Loading...

When clicking the button, a DotNetObjectReference object is created and invoked with the TextControl.saveDocument JavaScript method. In this method, the document is saved and passed to the .NET method ProcessDocument (see code above).

Loading...

In the .NET method ProcessDocument, the saved document is loaded into a ServerTextControl instance to add additional text. Finally, it is saved back by invoking another JavaScript method TextControl.loadDocument to load the modified document into the document editor.

Conclusion

This data flow shows how to use the document editor and the server-side non-UI components of TX Text Control in combination in Blazor Server Apps.

You can test this data flow using the sample project that is hosted in our GitHub account.