In the implementation of the MailMerge class, a SubTextPart is used for repeating blocks in a reporting template. But the SubTextParts can be used for many different applications such as adding comments or to store additional hidden information to text ranges.
This sample shows how to insert a SubTextPart to protect a section from being edited by the user. The ID property is used to mark the SubTextPart as editable (0) or non-editable (1). In order to insert this special SubTextPart, an HTTP Post method is implemented in the MVC controller:
This method creates a ServerTextControl that is used to load the selected text of the Web.TextControl. This text is converted into a SubTextPart and saved in the internal Unicode format to be returned to the client.
If the caret is entering and leaving these SubTextParts, events are triggered that are used to set the editMode property of Web.TextControl either to ReadAndSelect or Edit mode.
In the following screenshot, you can see an activated SubTextPart which is protected. The ribbon bar is disabled as the content is not editable inside this protected section.
Download the sample from GitHub and test it on your own.
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 2015 or better
- TX Text Control .NET Server for ASP.NET (trial sufficient)