Example of IFrame in ASP.NET MVC Rich Text Editor Control
This sample demonstrates the default rendering of the Rich Text Editor in iframe mode .
A paragraph of the page.
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "iframeEditor",
Name = "Iframe",
Height = "340px",
IframeSettings = new UiRichTextIframe { Enable = true },
Value = (string)ViewData["RTEValue"]
})
<div class="rte-red-paragraphs">
<p>A paragraph of the page.</p>
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "iframeEditor",
Name = "Iframe",
Height = "340px",
IframeSettings = new UiRichTextIframe { Enable = true },
Value = (string)ViewData["RTEValue"]
})
</div>
<style>
.rte-red-paragraphs p { color: #c4314b; }
</style>
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/Iframe.cshtml; it draws what ViewData holds.
public ActionResult Iframe()
{
ViewData["RTEValue"] = "<h3>Inside the frame</h3><p>This paragraph keeps the editor's own look.</p><ul><li>Formats</li><li>Lists</li><li>Tables and links</li></ul>";
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>
The Rich Text Editor is WYSIWYG ("what you see is what you get") editor that is used to create and edit content, and return valid HTML markup. The editor provides a standard toolbar to format content using its commands. The toolbar contains commands to align the text, insert link, insert image, insert list, undo/redo the operation, HTML view, and more.