# Content Controls

> Load MS Word content controls into the Document Editor as form fields, save them back to DOCX and read tags on the server with ContentControlFieldAdapter.

- **Product:** TX Text Control .NET Server
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET Server > Document Editor > Content Controls
- **1829 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/content-controls/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/content-controls/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/content-controls/llms-full.txt

---

Forms and templates created in MS Word can contain content controls. When your users open such documents in the Document Editor, it matters how content controls appear after a DOCX document is loaded, how your code works with them and what is written back when the document is saved.

### What Content Controls Are

Content controls are the form elements of MS Word documents, such as text boxes, check boxes, drop-down lists, combo boxes and date pickers. They replaced the older legacy form fields of MS Word and are stored in DOCX documents.

TX Text Control has no content control object in the Document Editor. When it loads a document, it converts content controls into its own fields, and when it saves a DOCX document, it writes them back as content controls.

### Content Controls in Loaded Documents

When a DOCX document with content controls is loaded into a visual TX Text Control such as the Document Editor, the content controls are shown as form fields by default. Each type becomes the matching form field:

| MS Word content control | Form field in TX Text Control |
|---|---|
| Text | Text form field (`TextFormField`) |
| Check box | Check box (`CheckFormField`) |
| Drop-down list, combo box | Selection form field (`SelectionFormField`) |
| Date picker | Date form field (`DateFormField`) |

Users fill them out and edit them like any other form field, and your code works with them through the form field API described on [Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/form-fields/llms-full.txt).

The load settings decide the conversion. The `applicationFieldFormat` setting of [LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol-loadsettings/llms-full.txt) takes a value of [ApplicationFieldFormat](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/applicationfieldformat-enumeration/llms-full.txt):

| Value | Content controls become |
|---|---|
| `None` | Form fields |
| `MSWordTXFormFields` | Form fields; other MS Word fields become application fields |
| `MSWord` | Application fields, which keep the raw data of the content control |

Application fields are described on [Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/fields/llms-full.txt).

### Read the Converted Fields

The following view loads a DOCX document with content controls, lists the form fields they became and saves the document as DOCX again. Save a document named *contentcontrols.docx* with content controls in the *Documents* folder of the project from the [ASP.NET Core](https://docs.textcontrol.com/tx-text-control-dotnet-server/getting-started/document-editor/aspnet-core/llms-full.txt) tutorial, and replace the content of *Views/Home/Index.cshtml*:

```cshtml
@using TXTextControl.Web.MVC

@Html.TXTextControl().TextControl().LoadText(
    "Documents/contentcontrols.docx",
    TXTextControl.Web.StreamType.WordprocessingML).Render()

<input type="button" onclick="listFormFields()" value="List Form Fields" />
<input type="button" onclick="saveAsDocx()" value="Save as DOCX" />

<script>
    function listFormFields() {
        TXTextControl.getTextFieldsByType(TXTextControl.TextFieldType.FormFields, function (fields) {
            fields.forEach(function (field) {
                console.log(field.name + ": " + field.text);
            });
        }, function (error) {
            console.log(error.msg);
        });
    }

    function saveAsDocx() {
        TXTextControl.saveDocument(TXTextControl.StreamType.WordprocessingML, function (result) {
            // result.data contains the DOCX document as a Base64 string for your server
            console.log(result.data.length + " characters of DOCX data");
        });
    }
</script>
```

- [LoadText](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loadtext-method/llms-full.txt) loads the DOCX document when the view is rendered.
- [getTextFieldsByType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/formattedtext/gettextfieldsbytype-method/llms-full.txt) with `FormFields` from [TextFieldType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/textfieldtype-enumeration/llms-full.txt) passes the names and texts of all form fields, including those that were content controls.
- [saveDocument](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/javascript/txtextcontrol/savedocument-method/llms-full.txt) with `WordprocessingML` saves the document as DOCX.

Click **List Form Fields** and open the browser console to see the fields of the document.

### Content Controls in Saved Documents

Which kind of field a form field becomes depends on the format you save in:

| Format | Form fields are saved as |
|---|---|
| DOCX | Content controls |
| DOC, RTF | Legacy MS Word form fields |
| PDF | PDF form fields |
| TX Text Control format | TX Text Control form fields |

A form that users fill out in the editor therefore opens in MS Word with content controls again when you save it as DOCX. The Document Editor uses the Core engine, which doesn't save DOC documents.

### Content Controls on the Server

On the server, the `TXTextControl.DocumentServer.Fields` namespace has classes that read and change the properties of content controls, such as their title and tag, which the form fields of the editor don't expose. They work with documents loaded with the `MSWord` application field format and wrap an application field of `ServerTextControl`: [ContentControlFieldAdapter](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/llms-full.txt) is the base class, with [PlainTextContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/plaintextcontentcontrol/llms-full.txt), [RichTextContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/richtextcontentcontrol/llms-full.txt), [CheckBoxContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/checkboxcontentcontrol/llms-full.txt), [ComboBoxContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/comboboxcontentcontrol/llms-full.txt), [DropDownListContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/dropdownlistcontentcontrol/llms-full.txt) and [DateContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-fields/datecontentcontrol/llms-full.txt) for the types. [Content Controls](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-processing/content-controls/llms-full.txt) in Document Processing describes them.

The blog article [Working with Content Controls in MS Word Documents using TX Text Control in C#](https://www.textcontrol.com/blog/2024/03/04/working-with-content-controls-in-ms-word-documents-using-tx-text-control-in-c-sharp/) reads content controls with these classes.

### Next Steps

- [Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/form-fields/llms-full.txt): work with the converted content controls.
- [Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/fields/llms-full.txt): application fields and other fields.
- [Loading and Saving Documents](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/load-save/llms-full.txt): load and save DOCX documents.

---

## Nearby

- **Previous:** [Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/form-fields/llms-full.txt)
- **Next:** [Signature Fields](https://docs.textcontrol.com/tx-text-control-dotnet-server/document-editor/signature-fields/llms-full.txt)
