# docx-editor-comments

> Document editor demonstrating threaded comments and at-mention support in the document.

**Framework:** aspnet-mvc  **Component:** DocxEditor  **Variant:** comments

## 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-mvc/docx-editor-comments.json
```

**Install Package(s)**

```bash
Install-Package Syncfusion.AspNetMvc.DocumentEditor
```

**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-comments/DocxEditor.cshtml

```cshtml
@using Syncfusion.EJ2
@section ControlsSection{
    <div class="control-section">
        <div class="flex-container">
            <label class="switchLabel" for="checked">Ribbon UI</label>
            @*<div class="e-message render-mode-info">
                    <span class="e-msg-icon render-mode-info-icon" title="Turn OFF to switch from Ribbon to toolbar UI"></span>
                </div>
                @Html.EJS().Switch("toolbarSwitch").CssClass("buttonSwitch").Change("onSwitchChange").Checked(true).Render()*@
        </div>
        <div id='documenteditor_titlebar' class="e-de-ctn-title"></div>
        @Html.EJS().DocumentEditorContainer("container").Height("590px").CurrentUser("Nancy Davolio").UserColor("#b70f34").EnableToolbar(true).Render()
    </div>
    <script src="~/Scripts/documenteditor/default-properties.js"></script>
}

@section Scripts{
    <script>
        var documenteditor;
        ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar, ej.documenteditor.Ribbon);

document.addEventListener('DOMContentLoaded', function () {
            var documenteditorElement = document.getElementById("container");
            documenteditorElement.style.height = "590px";
            documenteditorElement.style.width = "100%";
            var container = documenteditorElement.ej2_instances[0];
            container.toolbarMode = "Ribbon";
            container.showPropertiesPane = false;
            container.documentEditorSettings.showRuler = true;
            var mentionData = [
                { "Name": "Selma Rose", "Eimg": "3", "EmailId": "selma@mycompany.com" },
                { "Name": "Russo Kay", "Eimg": "8", "EmailId": "russo@mycompany.com" },
                { "Name": "Camden Kate", "Eimg": "9", "EmailId": "camden@mycompany.com" },
            ];
            container.documentEditorSettings.mentionSettings = { dataSource: mentionData, fields: { text: 'Name' }}
            container.documentEditorSettings.commentSettings.highlightCommentsByAuthor = true;
            documenteditor = container.documentEditor;
            documenteditorElement.ej2_instances[0].serviceUrl = window.baseurl + 'api/documenteditorservice/';
            documenteditor.serviceUrl = window.baseurl + 'api/documenteditorservice/';
            var ajax = new ej.base.Ajax("@Url.Content("~/scripts/documenteditor/data-comments.json")", 'GET', true);
            ajax.send().then();
            ajax.onSuccess = function (data) {
                documenteditor.open(data);
                documenteditor.documentName = 'Comments';
                documenteditor.showComments = true;
                updateDocumentTitle();
            };
            container.documentChange = function (args) {
                 updateDocumentTitle();
            };
            container.commentDelete = function (args) {
                if (args.author !== documenteditor.currentUser) {
                    args.cancel = true;
                    ejs.popups.DialogUtility.alert({
                        title: 'Information',
                        content: 'Delete restriction enabled. Only the author of the comment can delete it.',
                        showCloseIcon: true,
                        closeOnEscape: true,
                    });
                }
            };
            var exportItem = {
                text: 'Export',
                id: 'custom_item',
                iconCss: 'e-icons e-export',
                items: [
                    { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },
                    { id: 'docx', text: 'Word Document (*.docx)' },
                    { id: 'dotx', text: 'Word Template (*.dotx)' },
                    { id: 'text', text: 'Plain Text (*.txt)' },
                    { id: 'pdf', text: 'PDF (*.pdf)' },
                    { id: 'html', text: 'HyperText Markup Language (*.html)' },
                    { id: 'rtf', text: 'Rich Text Format (*.rtf)' },
                    { id: 'md', text: 'Markdown (*.md)' },
                    { id: 'odt', text: 'OpenDocument Text (*.odt)' },
                    { id: 'wordml', text: 'Word XML Document (*.xml)' },
                ],
            };
            container.fileMenuItems = ['New', 'Open', exportItem, 'Print'];
            container.fileMenuItemClick = function (args) {
                if (args.item.id) {
                    var value = args.item.id;
                    var sampleName = container.documentEditor.documentName === '' ? 'sample' : container.documentEditor.documentName;
                    switch (value) {
                        case 'docx':
                            container.documentEditor.save(sampleName, 'Docx');
                            break;
                        case 'sfdt':
                            container.documentEditor.save(sampleName, 'Sfdt');
                            break;
                        case 'text':
                            container.documentEditor.save(sampleName, 'Txt');
                            break;
                        case 'dotx':
                            container.documentEditor.save(sampleName, 'Dotx');
                            break;
                        case 'pdf':
                            saveFormat('Pdf');
                            break;
                        case 'html':
                            saveFormat('Html');
                            break;
                        case 'odt':
                            saveFormat('Odt');
                            break;
                        case 'md':
                            saveFormat('Md');
                            break;
                        case 'rtf':
                            saveFormat('Rtf');
                            break;
                        case 'wordml':
                            saveFormat('Xml');
                            break;
                    }
                }
            };
            container.dataBind();
            titleBarDiv = document.getElementById('documenteditor_titlebar');
            initComponentAndWireEvent();
        showButtons(false);
        });

        function saveFormat(type) {
            var spinTarget = document.getElementById('container');
            ej.popups.createSpinner({
                target: spinTarget
            });
            ej.popups.showSpinner(spinTarget);
            var container = document.getElementById("container").ej2_instances[0];
            var format = type;
            var url = window.baseurl + 'api/documenteditorservice/Export';
            var http = new XMLHttpRequest();
            http.open('POST', url);
            http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
            var sfdt = {
                Content: container.documentEditor.serialize(),
                Filename: container.documentEditor.documentName,
                Format: '.' + format
            };
            http.onload = function () {
                if (http.status === 200) {
                    var responseData = http.response;
                    var downloadLink = document.createElement('a');
                    downloadLink.href = responseData;
                    downloadLink.download = container.documentEditor.documentName + '.' + (format).toLowerCase();
                    document.body.appendChild(downloadLink);
                    ej.popups.hideSpinner(spinTarget);
                    downloadLink.click();
                    document.body.removeChild(downloadLink);
                }
                else {
                    console.error('Request failed with status:', http.status);
                    ej.popups.hideSpinner(spinTarget);
                }
            };
            http.send(JSON.stringify(sfdt));
        }
    </script>
}

<style>
    #container {
        display: block;
        height: 500px;
    }

    .flex-container {
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }

    .render-mode-info {
        background: none;
        border: none;
        padding-left: 0px;
    }

        .render-mode-info .render-mode-info-icon {
            height: 16px;
            width: 16px;
        }

    .switchLabel {
        font-family: "Segoe UI", "GeezaPro", "DejaVu Serif", sans-serif;
        font-weight: 400;
        line-height: 20px;
        letter-spacing: 0.24px;
        text-align: right;
        font-size: 14px;
        margin-bottom: 0px;
    }

    .render-mode-info .render-mode-info-icon::before {
        line-height: normal;
    }

    .buttonSwitch {
        Width: 40px;
        Height: 24px;
    }

    #documenteditor_titlebar {
        border-bottom: 1px solid #2B3481;
        height: 36px;
        line-height: 26px;
        width: 100%;
        font-size: 12px;
        padding-left: 15px;
        padding-right: 10px;
        font-family: inherit;
    }

    #documenteditor_title_contentEditor {
        height: 26px;
        max-width: 85%;
        width: auto;
        overflow: hidden;
        display: inline-block;
        padding-left: 4px;
        padding-right: 4px;
        margin: 5px;
    }

    .single-line {
        cursor: text !important;
        outline: none;
    }

        .single-line:hover {
            border-color: #e4e4e4 !important;
        }

    [contenteditable="true"].single-line {
        white-space: nowrap;
        border-color: #e4e4e4 !important;
    }

    @@font-face {
        font-family: 'Sample brower icons';
        font-weight: normal;
        font-style: normal;
    }

    [class^="e-de-icon-"],
    [class*=" e-de-icon-"] {
        font-family: 'Sample brower icons' !important;
    }

    .e-de-icon-Print:before {
        content: "\e723";
    }

    .e-de-icon-Download:before {
        content: "\e728";
    }
</style>

```

### src/components/docx-editor-comments/DocxEditorController.cs

```cs
using Syncfusion.EJ2.Navigations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EJ2MVCSampleBrowser.Controllers.DocumentEditor
{
    public partial class DocumentEditorController : Controller
    {
        public ActionResult Comments()
        {
            this.DocumentEditorViewResultHelper();
            return View("~/Views/Home/docx-editor/comments/DocxEditor.cshtml");
        }
    }
}
```
