Getting Started with ASP.NET Core Rich Text Editor

The ASP.NET Core Rich Text Editor is a WYSIWYG (What You See Is What You Get) editor that enables users to create, edit, and format rich text content with features like multimedia insertion, lists, and links. This section briefly explains about how to include ASP.NET Core Rich Text Editor control in your ASP.NET Core application using Visual Studio.

Ready to streamline your ASP.NET Core development? Discover the full potential of ASP.NET Core controls with AI Coding Assistant. Effortlessly integrate, configure, and enhance your projects with intelligent, context-aware code suggestions, streamlined setups, and real-time insights—all seamlessly integrated into your preferred AI-powered IDEs like Visual Studio, Visual Studio Code, Cursor, CodeStudio and more. Explore AI Coding Assistant

To get started quickly with ASP.NET Core Rich Text Editor, you can check on this video:

Create an ASP.NET Core Web App with Razor Pages

Create an ASP.NET Core Web App using Visual Studio via Microsoft Templates or the Syncfusion® ASP.NET Core Extension. For detailed instructions, refer to the ASP.NET Core Web App Getting Started documentation.

Run the following command to create a new ASP.NET Core Web App.

dotnet new webapp -o RazorPagesMovie
code -r RazorPagesMovie

Alternatively, create an ASP.NET Core Web App using Visual Studio Code via Microsoft Templates, or the Syncfusion® ASP.NET Core Extension, or the C# Dev Kit extension.

Install the required ASP.NET Core packages

Install Syncfusion.AspNetCore.RichTextEditor and Syncfusion.AspNetCore.Themes NuGet packages. All Syncfusion ASP.NET Core packages are available in nuget.org. See the NuGet packages topic for the details.

  1. Go to Tools → NuGet Package Manager → Manage NuGet Packages for Solution.
  2. Search the required NuGet package (Syncfusion.AspNetCore.RichTextEditor and Syncfusion.AspNetCore.Themes ) and install them.

Alternatively, you can install the same packages using the Package Manager Console with the following commands.

Install-Package Syncfusion.AspNetCore.RichTextEditor -Version 34.2.2
Install-Package Syncfusion.AspNetCore.Themes -Version 34.2.2

Open the terminal and run the following commands.

dotnet add package Syncfusion.AspNetCore.RichTextEditor --version 34.2.2
dotnet add package Syncfusion.AspNetCore.Themes -Version --version 34.2.2

Add the ASP.NET Core Tag Helpers

After the packages are installed, open the ~/Pages/_ViewImports.cshtml file and import the Syncfusion.AspNetCore.Base and Syncfusion.AspNetCore.RichTextEditor Tag Helpers.

@addTagHelper *, Syncfusion.AspNetCore.Base
@addTagHelper *, Syncfusion.AspNetCore.RichTextEditor

Add stylesheet and script resources

The theme stylesheet and script can be referenced from CDN. Include the stylesheet and script references inside the <head> of ~/Pages/Shared/_Layout.cshtml

<head>
    ...
    <!-- Syncfusion ASP.NET Core controls styles -->
    <link rel="stylesheet" href="_content/Syncfusion.AspNetCore.Themes/styles/fluent2.css" />
    <!-- Syncfusion ASP.NET Core controls scripts -->
    <script src="_content/Syncfusion.AspNetCore.RichTextEditor/scripts/sf-rich-text-editor.min.js"></script>
</head>

Register the Script Manager

Open the ~/Pages/Shared/_Layout.cshtml file and register the script manager <ejs-scripts> at the end of the <body> element as follows.

<body>
    ...
    <!-- ASP.NET Core Script Manager -->
    <ejs-scripts></ejs-scripts>
</body>

Add ASP.NET Core Rich Text Editor control

Add the ASP.NET Core Rich Text Editor control in the ~/Pages/Index.cshtml file.

<ejs-richtexteditor id="editor"></ejs-richtexteditor>

IMPORTANT

When the Rich Text Editor control is rendered, the id attribute must be provided; otherwise, the control will fail to render.

Run the application

Press Ctrl+F5 (Windows) or +F5 (macOS) to launch the application. The ASP.NET Core Rich Text Editor control will render in your default web browser.

Open the terminal and run the following command.

dotnet run

ASP.NET Core Rich Text Editor Control

NOTE

View Sample in GitHub.

See Also

  1. Getting Started with ASP.NET Core using Razor Pages
  2. Getting Started with ASP.NET Core MVC using Tag Helper
  3. Blog posting using Rich Text Editor
  4. How to change the editor type
  5. How to render the iframe
  6. Accessibility in Rich text editor
  7. Keyboard support in Rich text editor
  8. Globalization in Rich text editor