| layout | post |
|---|---|
| title | Getting Started with ASP.NET MVC DOCX Editor | Syncfusion |
| description | Learn how to create a DOCX Editor in an ASP.NET MVC application using the Syncfusion® Document Editor control to create, edit, and view Word documents. |
| platform | document-processing |
| control | Getting Started |
| documentation | ug |
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.
This section briefly explains about how to include Document Editor control in your ASP.NET MVC application using Visual Studio.
System requirements for ASP.NET MVC controls
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.
{% tabs %} {% highlight C# tabtitle="Package Manager" %}
Install-Package Syncfusion.EJ2.MVC5
{% endhighlight %} {% endtabs %}
N> This package includes dependencies such as Newtonsoft.Json for JSON serialization and Syncfusion.Licensing for license validation.
Add the Syncfusion.EJ2 namespace reference to the <namespaces> section in the ~/Views/Web.config file.
{% tabs %} {% highlight C# tabtitle="Web.config" %}
{% endhighlight %} {% endtabs %}
Here, the theme and script is referred using CDN inside the <head> of ~/Views/Shared/_Layout.cshtml file as follows,
{% tabs %} {% highlight cshtml tabtitle="~/_Layout.cshtml" %}
<script src="https://cdn.syncfusion.com/ej2/{{ site.ej2version }}/dist/ej2.min.js"></script>{% endhighlight %} {% endtabs %}
N> 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.
Also, register the script manager EJS().ScriptManager() at the end of <body> in the ~/Views/Shared/_Layout.cshtml file as follows.
{% tabs %} {% highlight cshtml tabtitle="~/_Layout.cshtml" %}
@Html.EJS().ScriptManager()
{% endhighlight %} {% endtabs %}
Add the Document Editor control in ~/Views/Home/Index.cshtml page.
{% tabs %} {% highlight cshtml tabtitle="~/Index.cshtml" %} @Html.EJS().DocumentEditorContainer("container").Height("590px").Render() {% endhighlight %} {% endtabs %}
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.
