Example of Resizable Editor in ASP.NET MVC Rich Text Editor Control
This sample demonstrates the resize operation of the Rich Text Editor control. To resize the Rich Text Editor, select and resize the editor using its handle (grip) at the bottom right corner of the content panel.
@* 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 = "resizableEditor",
EnableResize = true,
Height = "250px",
Value = (string)ViewData["RTEValue"]
})
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "resizableEditor",
EnableResize = true,
Height = "250px",
Value = (string)ViewData["RTEValue"]
})
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/ResizableEditor.cshtml; it draws what ViewData holds.
public ActionResult ResizableEditor()
{
ViewData["RTEValue"] = "<h2>The Greatest Lessons from Nature</h2><p>Nature is a powerful teacher, offering timeless wisdom through its beauty, resilience, and harmony. Here are three of the most important lessons we can learn from nature:</p>" +
"<p><strong>Adaptability & Resilience</strong> 🌿<br></p><p>Nature is constantly changing and evolving. Trees withstand storms, rivers carve through rocks, and animals adapt to new environments. Similarly, life challenges us, and, like nature, we must be flexible and resilient in order to overcome obstacles.</p>" +
"<p><strong>Patience & Growth</strong> 🌱</p><p>A seed does not become a tree overnight. Growth takes time, whether in nature or in our personal and professional lives. Success, wisdom, and strength develop through persistence, effort, and patience.</p>" +
"<p><strong>Balance & Harmony</strong> 🌎</p><p>Nature maintains a delicate balance throughout the day and night, across the seasons, and within ecosystems. It teaches us the importance of balance in our own lives between work and rest, giving and receiving, and action and reflection.</p>" +
"<p><br></p><p align=\"center\"><em>“Look deep into nature, and then you will understand everything better.” <strong>– Albert Einstein</strong></em></p>";
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>
Users can create a resizable Rich Text Editor by setting the EnableResize property to true, which is used to change the size of the Rich Text Editor
dynamically. Drag the grip at the bottom right corner, or focus it and use the up and down arrow keys. OnResizeStart, OnResizing
and OnResizeStop tell the height.