Syncfusion AI Assistant

How can I help you?

Getting Started with ASP.NET MVC DOCX Editor

28 Apr 20262 minutes to read

Syncfusion® DOCX Editor (Document Editor) enables you to create, edit, view, and print Word documents in web applications. This section guides you through the steps to get started and create a DOCX Editor in a ASP.NET MVC application.

Steps to create an ASP.NET MVC DOCX Editor

This section briefly explains about how to include ASP.NET MVC DOCX Editor control in your ASP.NET MVC application using Visual Studio.

Prerequisites

System requirements for ASP.NET MVC controls

Create ASP.NET MVC application with HTML helper

Install Syncfusion® ASP.NET MVC Nuget packages

To add ASP.NET MVC Document Editor component in the application, follow the steps below.

  • open NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution),
  • search and install the following package
Install-Package Syncfusion.EJ2.MVC5 -Version 33.2.3

NOTE

This package includes dependencies such as Newtonsoft.Json for JSON serialization and Syncfusion.Licensing for license validation.”

Add namespace

Add Syncfusion.EJ2 namespace reference in Web.config under Views folder.

<namespaces>
    <add namespace="Syncfusion.EJ2"/>
</namespaces>

Add Themes and Script References

Here, the theme and script is referred using CDN inside the <head> of ~/Views/Shared/_Layout.cshtml file as follows,

<head>
    ...
    <!-- Syncfusion ASP.NET MVC controls styles -->
    <link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/33.2.3/fluent.css" />
    <!-- Syncfusion ASP.NET MVC controls scripts -->
    <script src="https://cdn.syncfusion.com/ej2/33.2.3/dist/ej2.min.js"></script>
</head>

NOTE

Refer the Themes topic to learn the different ways to include Syncfusion styles (using CDN, NPM package, or CRG) and ensure the expected appearance of Syncfusion® ASP.NET MVC controls, and check the Adding Script Reference documentation to understand the various approaches for adding required script references in your ASP.NET MVC application.

Register Syncfusion® script manager

Also, register the script manager EJS().ScriptManager() at the end of <body> in the ~/Views/Shared/_Layout.cshtml file as follows.

<body>
    ...
    <!-- Syncfusion ASP.NET MVC Script Manager -->
    @Html.EJS().ScriptManager()
</body>

Add the Syncfusion® Document Editor component

Add the Syncfusion® ASP.NET MVC Document Editor control in ~/Views/Home/Index.cshtml page.

@Html.EJS().DocumentEditorContainer("container").Render()

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to run the app. Then, the Syncfusion® ASP.NET MVC Document Editor control will be rendered in the default web browser.

NOTE

You can download a complete working sample from GitHub.