Skip to main content
A newer version of this page is available. .

Overview - HtmlEditor

  • 2 minutes to read

The DevExpress HtmlEditor is a rich-text WYSIWYG HTML editor extension for ASP.NET MVC. Its intuitive user interface enables even inexperienced users to edit HTML page content with ease.

To learn more about HtmlEditor and see it in action, refer to its online demos.

Implementation Details

HtmlEditor is realized by the HtmlEditorExtension class. Its instance can be accessed via the ExtensionsFactory.HtmlEditor helper method, which is used to add a HtmlEditor extension to a view. This method’s parameter provides access to the HtmlEditor‘s settings implemented by the HtmlEditorSettings class, allowing you to fully customize the extension.

HtmlEditor‘s client counterpart is represented by the MVCxClientHtmlEditor object.

Declaration

HtmlEditor can be added to a view in the following manner.

View code - “Index” (Razor):

@using(Html.BeginForm()) {
    @Html.Partial("HtmlEditorPartial")
}

Note

To enable the file downloading and uploading functionality, the Partial View with the extension must be wrapped with the HTML form. Since this functionality is implemented through the UploadControl extension, it’s also necessary to fulfill all the recommendations from the corresponding KB article.

Note

The Partial View should contain only the extension’s code.

Partial View code - “HtmlEditorPartial” (Razor):

@Html.DevExpress().HtmlEditor(
    settings =>
    {
        settings.Name = "myHtmlEditor";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "HtmlEditorPart" };

        settings.Html = "Some content.";
    }).GetHtml()

Controller (“Home”):

    public class HomeController : Controller{

        public ActionResult Index(){
            return View();
        }

        public ActionResult HtmlEditorPart(){
            return PartialView("HtmlEditorPartial");
        }
    }

The code result is demonstrated in the image below.

htmleditor-declaration.png

See Also