# ASP.NET: Protected SubTextParts in TXTextControl.Web

> SubTextParts in TX Text Control define named text ranges with Start, Length, and Name properties. Version X14 adds subTextPartEntered and subTextPartLeft events to the HTML5-based Web.TextControl, allowing developers to switch editMode and create read-only document sections.

- **Author:** Bjoern Meyer
- **Published:** 2017-01-26
- **Modified:** 2026-03-05
- **Description:** SubTextParts in TX Text Control define named text ranges with Start, Length, and Name properties. Version X14 adds subTextPartEntered and subTextPartLeft events to the HTML5-based Web.TextControl, allowing developers to switch editMode and create read-only document sections.
- **1 min read** (142 words)
- **Tags:**
  - HTML5
  - Mail Merge
  - Release
- **Web URL:** https://www.textcontrol.com/blog/2017/01/26/aspnet-protected-subtextparts-in-txtextcontrolweb/
- **LLMs URL:** https://www.textcontrol.com/blog/2017/01/26/aspnet-protected-subtextparts-in-txtextcontrolweb/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2017/01/26/aspnet-protected-subtextparts-in-txtextcontrolweb/llms-full.txt

---

SubTextPartswere introduced in version X13 (23.0) as a new document element to realize the new MailMerge merge block concept. But this feature can be used for many other tasks as well.

In general, a SubTextPartis a defined range of text with a Start, a Lengthand a Name. This name can be used to tag a SubTextPartto be protected. If the user enters this SubTextPart, the editModecan be used to set TextControl to read only.

Version X14 (24.0) implements new events for the HTML5-based TXTextControl.Web: subTextPartEnteredand subTextPartLeft. Both events return the event argument SubTextPartEventArgsobject.

On leaving the SubTextPart, the subTextPartLeftis used to switch back to edit mode.

The following JavaScript code shows this easy implementation:

```
function subTextPartEnteredHandler(e) {
    if (e.name == "protected")
        TXTextControl.editMode = TXTextControl.EditMode.ReadAndSelect;
}

function subTextPartLeftHandler(e) {
    TXTextControl.editMode = TXTextControl.EditMode.Edit;
}

TXTextControl.addEventListener("subTextPartEntered", subTextPartEnteredHandler);
TXTextControl.addEventListener("subTextPartLeft", subTextPartLeftHandler);
```

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [MailMerge: Conditional Rendering of Merge Blocks](https://www.textcontrol.com/blog/2018/11/28/mailmerge-conditional-rendering-of-merge-blocks/llms.txt)
- [DataSourceManager: Using the Ready-to-Use Reporting Dialog Boxes](https://www.textcontrol.com/blog/2018/11/27/datasourcemanager-using-the-ready-to-use-reporting-dialog-boxes/llms.txt)
- [Merge Blocks in X16: Filtering, Sorting and Conditional Rendering](https://www.textcontrol.com/blog/2018/11/22/merge-blocks-in-x16-filtering-sorting-and-conditional-rendering/llms.txt)
- [X15: Adding MS Word Compatible Fields and Form Elements to TXTextControl.Web](https://www.textcontrol.com/blog/2017/12/20/using-ms-word-form-elements-in-txtextcontrol-web/llms.txt)
- [X15: Inserting Client-Side Images using JavaScript](https://www.textcontrol.com/blog/2017/12/14/inserting-client-side-images-using-javascript/llms.txt)
- [Sneak Peek X15: Copy to Local Clipboard Support in ASP.NET Version](https://www.textcontrol.com/blog/2017/07/13/sneak-peek-x15-copy-to-local-clipboard-support-in-aspnet-version/llms.txt)
- [More Impressions from DWX Developer Week 2017](https://www.textcontrol.com/blog/2017/06/29/more-impressions-from-dwx-developer-week-2017/llms.txt)
- [DWX Developer Week 2017: First Impressions](https://www.textcontrol.com/blog/2017/06/27/dwx-developer-week-2017-first-impressions/llms.txt)
- [Sneak Peek X15: Custom Field Overlays in HTML5-based Text Control](https://www.textcontrol.com/blog/2017/06/21/sneak-peek-x15-custom-field-overlays-in-html5-based-text-control/llms.txt)
- [NDC Oslo 2017 Impressions: Part II](https://www.textcontrol.com/blog/2017/06/19/ndc-oslo-2017-impressions-part-ii/llms.txt)
- [First Day at NDC Oslo 2017: Some Impressions](https://www.textcontrol.com/blog/2017/06/15/first-day-at-ndc-oslo-2017-some-impressions/llms.txt)
- [Impressions from DevIntersection Spring in Orlando, FL](https://www.textcontrol.com/blog/2017/05/23/impressions-from-devintersection-spring-in-orlando-fl/llms.txt)
- [Impressions from Magdeburger Developer Days 2017](https://www.textcontrol.com/blog/2017/05/15/impressions-from-magdeburger-developer-days-2017/llms.txt)
- [Impressions from Dotnet Cologne 2017](https://www.textcontrol.com/blog/2017/05/08/impressions-from-dotnet-cologne-2017/llms.txt)
- [Impressions from Philly Code Camp 2017](https://www.textcontrol.com/blog/2017/02/27/impressions-from-philly-code-camp-2017/llms.txt)
- [Impressions from BASTA! Spring 2017, Frankfurt](https://www.textcontrol.com/blog/2017/02/25/impressions-from-basta-spring-2017-frankfurt/llms.txt)
- [More Impressions from NDC London 2017](https://www.textcontrol.com/blog/2017/01/25/more-impressions-from-ndc-london-2017/llms.txt)
- [Impressions from NDC London 2017](https://www.textcontrol.com/blog/2017/01/18/impressions-from-ndc-london-2017/llms.txt)
- [HTML5: Using the New JavaScript Selection Object](https://www.textcontrol.com/blog/2016/12/24/html5-using-the-new-javascript-selection-object/llms.txt)
- [MailMerge Improvements in X14: Event Arguments and JSON Data Sources](https://www.textcontrol.com/blog/2016/11/01/mailmerge-improvements-in-x14-event-arguments-and-json-data-sources/llms.txt)
- [Impressions from DevIntersection 2016, Las Vegas - Roadmap for Version X14](https://www.textcontrol.com/blog/2016/10/30/impressions-from-devintersection-2016-las-vegas-roadmap-for-version-x14/llms.txt)
- [Preview: JSON Support in MailMerge Version X14 (24.0)](https://www.textcontrol.com/blog/2016/05/18/preview-json-support-in-mailmerge-version-x14-240/llms.txt)
- [X13: Using IMEs and Localization in Web.TextControl](https://www.textcontrol.com/blog/2015/11/20/x13-using-imes-and-localization-in-webtextcontrol/llms.txt)
- [X13: New Web Forms DocumentViewer Style](https://www.textcontrol.com/blog/2015/11/19/x13-new-web-forms-documentviewer-style/llms.txt)
- [Sneak Peek X13: New Features in Web.TextControl](https://www.textcontrol.com/blog/2015/11/18/sneak-peek-x13-new-features-in-webtextcontrol/llms.txt)
