Restrict Editing in ASP.NET Core DOCX Editor

14 Aug 20262 minutes to read

ASP.NET Core DOCX Editor (Document Editor) provides support to restrict editing. When a protected document includes range permissions, only the specified user or user group is authorized to edit their assigned text areas.

Set Current User

Use the currentUser property to authorize the current user of the document by name, email, or user group name.

The following example sets the currentUser.

container.documentEditor.currentUser = '[email protected]';

Protect document with editable region

A user can select a specific section and mark it as an editable region, allowing modification only in that part. The rest of the document remains protected from any changes.

Insert editable region

Use the insertEditingRegion method to mark specific paragraphs as editable. This allows you to control editing by giving access to all users or only selected users.

The following example shows how to insert an editable region.

// Allow editing for all users
container.documentEditor.editor.insertEditingRegion();
 
// pass a username to restrict access
container.documentEditor.editor.insertEditingRegion("User Name");

Highlight color for editable region

Use the userColor property to highlight the editable region of the current user.

The following example sets the userColor.

container.documentEditor.userColor = '#fff000';

Enable or disable editable region highlighting

Use the highlightEditableRanges property to toggle the highlighting of editable regions.

The following example enables or disables editable region highlighting.

container.documentEditor.documentEditorSettings.highlightEditableRanges = true;

Restrict Editing Pane

The Restrict Editing Pane provides the following options to manage the document:

  • To apply formatting restrictions to the current document, select the Allow formatting check box.
  • To apply editing restrictions to the current document, select the Read only check box.
  • To add users to the current document, select the More users option and add users from the popup dialog.
  • To include range permission for the current document, select parts of the document and choose the users who are allowed to freely edit them from the listed check boxes.
  • To apply the chosen editing restrictions, click the Yes, Start Enforcing Protection button. A dialog prompts for a password to protect the document.
  • To stop protection, click Stop Protection. A dialog prompts for the protection password.

Online Demo

Explore how to restrict editing and protect Word documents using the ASP.NET Core Document Editor in this live demo here.

See Also