Example of Default Functionalities in ASP.NET MVC Markdown Editor Control
This sample demonstrates markdown editing in the Markdown Editor with complete features.
@* The editor's settings are in the view; the data they read (ViewData) is set in the controller action (see the controller tab). *@
@Html.UiMarkdownEditor(new UiMarkdownEditorOptions
{
Id = "defaultMarkDown",
Height = "520px",
Placeholder = "Enter your text here...",
ToolbarSettings = new UiMarkdownToolbar { Items = (List<string>)ViewData["Tools"] },
Value = (string)ViewData["MDValue"]
})
@Html.UiMarkdownEditor(new UiMarkdownEditorOptions
{
Id = "defaultMarkDown",
Height = "520px",
Placeholder = "Enter your text here...",
ToolbarSettings = new UiMarkdownToolbar { Items = (List<string>)ViewData["Tools"] },
Value = (string)ViewData["MDValue"]
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class MarkdownEditorController : Controller
{
// The page is Views/MarkdownEditor/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
ViewData["Tools"] = new List<string>
{
"Bold", "Italic", "StrikeThrough", "|", "Formats", "Blockquote", "OrderedList", "UnorderedList", "Superscript", "Subscript", "|", "CreateTable",
"CreateLink", "Image", "|", "Preview", "|", "Undo", "Redo"
};
ViewData["MDValue"] = @"# 🚀 My Project
A simple yet powerful project that does amazing things.
**Bold text** for emphasis, *italic* for subtlety, ~~strikethrough~~ for corrections, and <u>underline</u> for highlights.
## ✨ Features
- Fast and efficient
- Easy to use
- Fully customizable
## 🛠 How to Use
1. Download the file
2. Open it directly
3. Start using immediately
## 🤝 Contributing
Check out our **Contributing Guide** for details.
## 📄 License
This project is licensed under the **MIT License** – see the LICENSE file for details.";
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 Markdown Editor supports markdown editing: its toolbar writes the Markdown around selected text, and its plain-text value can be submitted through a standard HTML form.
The editor’s toolbar contains commands to format the markdown content. The toolbar consists of:
Lists– Ordered and unordered list types.Links– A hyperlink can be inserted into the editor for quick access to related information.Image– Inserts an image.Format– Formats the sentence in different ways such as heading level, quotation, and code snippet.Styles– Allows you to apply inline styles to the selected content like bold, italic, strikethrough, superscript and subscript.Tables– Allows you to insert a table with header.Preview– Shows the result in place of the text, and the text again when it is used a second time.