Syncfusion AI Assistant

How can I help you?

Getting Started with ASP.NET MVC DOCX Editor

26 May 20263 minutes to read

Syncfusion® ASP.NET MVC 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 Document 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 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

Alternatively, you can utilize the following package manager command to achieve the same.

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 Document Editor component

Add the Document Editor control in ~/Views/Home/Index.cshtml page.

@Html.EJS().DocumentEditorContainer("container").Height("590px").Render()

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to run the app. Then, Document Editor control will be rendered in the default web browser as shown below.

Output of ASP.NET MVC DOCX Editor

NOTE

View Sample in GitHub.

See also