# docx-editor-document-protection

> Document editor demonstrating document protection settings and restricted editing modes.

**Framework:** aspnet-core  **Component:** DocxEditor  **Variant:** document-protection

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/aspnet-core/docx-editor-document-protection.json
```

**Install Package(s)**

```bash
dotnet add package Syncfusion.AspNetCore.DocumentEditor
dotnet add package Syncfusion.AspNetCore.Inputs
dotnet add package Syncfusion.AspNetCore.DropDowns
```

**Notes**

- Syncfusion release: 2026 Volume 3 (v35.1.37)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-document-protection/docx-editor.cshtml

```cshtml
@page
@namespace aspnet_core.DocxEditor.DocumentProtection
@using Syncfusion.EJ2

    <div class="control-section">
        <div class="content-wrapper">
            <div class="heading-section">
                <h5><b>User Permission</b></h5>
            </div>
            <div class="control-label"><b>Current User</b></div>
            <ejs-dropdownlist id="ddlelement" placeholder="Select User" index="0" dataSource="@(new string[] { "user.one@example.com", "user.two@example.com" })"></ejs-dropdownlist>
            <div class="control-label"><b>User Color</b></div>
            <ejs-colorpicker id="color-picker" value="#b70f34"></ejs-colorpicker>
        </div>
        <div id='documenteditor_titlebar' class="e-de-ctn-title"></div>
        <ejs-documenteditorcontainer id="container" height="590px" enableToolbar="true"></ejs-documenteditorcontainer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var container = document.getElementById('container').ej2_instances[0];
            if (!container) return;
            // Lock the entire document so the selected user is the only
            // one allowed to make changes.
            container.documentEditor.editor.enforceProtection('password123', 'ReadOnly');
            var userMenu = document.getElementById('ddlelement').ej2_instances[0];
            var colorPicker = document.getElementById('color-picker').ej2_instances[0];
            userMenu.change = function (e) {
                if (container && container.documentEditor) {
                    container.documentEditor.currentUser = e.value;
                }
            };
            colorPicker.change = function (e) {
                if (container && container.documentEditor && e.currentValue) {
                    container.documentEditor.userColor = e.currentValue.hex;
                }
            };
        });
    </script>

```
