Example of Bottom Toolbar in ASP.NET MVC Rich Text Editor Control
This sample demonstrates the Bottom Toolbar of the Rich Text Editor with minimum configuration and includes a Chat UI interface.
@* The editor's settings are in the view; the data they read (ViewData) is set in the controller action (see the controller tab). *@
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "bottomEditor",
Name = "Comment",
Height = "220px",
Placeholder = "Write a comment...",
ToolbarSettings = new UiRichTextToolbar
{
Position = UiRichTextToolbarPosition.Bottom,
Items = (List<string>)ViewData["Tools"]
}
})
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "bottomEditor",
Name = "Comment",
Height = "220px",
Placeholder = "Write a comment...",
ToolbarSettings = new UiRichTextToolbar
{
Position = UiRichTextToolbarPosition.Bottom,
Items = (List<string>)ViewData["Tools"]
}
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class RichTextEditorController : Controller
{
// The page is Views/RichTextEditor/BottomToolbar.cshtml; it draws what ViewData holds.
public ActionResult BottomToolbar()
{
ViewData["Tools"] = new List<string> { "Bold", "Italic", "Underline", "StrikeThrough", "|", "OrderedList", "UnorderedList", "|", "CreateLink", "InlineCode", "|", "Undo", "Redo" };
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
In this example, the toolbar is positioned at the bottom of the editor. The position of the toolbar can be customized by using the toolbarSettings.position property.
Additionally, this sample includes a Chat UI interface that allows users to communicate using a Rich Text Editor for message composition.