Example of Code Editor Layout in ASP.NET MVC Splitter Control
This example demonstrates the splitter control that is used to design code editor-like application using multiple panes. You can resize its panes vertically as well as horizontally.
<!DOCTYPE html> <html> <body> <div id="custom-image"> <img src="src/albert.png" alt="albert"> </div> </body> </html>
img {
margin: 0 auto;
display: flex;
height: 70px;
}var image = document.getElementById("custom-image");
image.addEventListener("click", function () {
// Code block for click action
});Preview of sample

@Html.UiSplitter(new UiSplitterOptions
{
Id = "outerSplitter", Orientation = UiSplitterOrientation.Vertical, Height = "400px", Width = "100%",
Panes =
{
new UiSplitterPane
{
Size = "53%", Min = "30%",
HtmlContent = Html.UiSplitter(new UiSplitterOptions
{
Id = "innerSplitter", Height = "100%",
Panes =
{
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">HTML</label><div class="code-preview"><pre><!DOCTYPE html>
<html>
<body>
<div id="custom-image">
<img src="src/albert.png" alt="albert">
</div>
</body>
</html></pre></div></div> },
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">CSS</label><div class="code-preview"><pre>img {
margin: 0 auto;
display: flex;
height: 70px;
}</pre></div></div> },
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">JavaScript</label><div class="code-preview"><pre>var image = document.getElementById("custom-image");
image.addEventListener("click", function () {
// Code block for click action
});</pre></div></div> }
}
})
},
new UiSplitterPane { Template = @<div id="splitter2"><h3 class="h3" style="padding: 5px">Preview of sample</h3><div class="splitter-image"><img class="img1" src="@Url.Content("~/Content/splitter/images/albert.png")" alt="albert" style="width: 20%; margin: 0 auto; display: block;" /></div></div> }
}
})
<style>
.control-section { padding: 10px 15px; }
.content { padding: 10px 12px; font-size: 14px; }
.content > a { font-weight: 600; }
#pane-heading { margin: 0 0 6px; font-weight: 600; }
#panetext { font-size: 13px; color: var(--ui-muted); }
.control_wrapper { max-width: 900px; margin: 0 auto; }
.code-editor-content { padding: 8px 12px; font-size: 13px; }
.code-editor-content .h3 { font-weight: 600; font-size: 15px; display: block; margin-bottom: 4px; }
.code-preview { font-family: Consolas, monospace; white-space: pre-wrap; }
.code-preview pre { margin: 0; font: inherit; }
.h3 { margin: 0; }
</style>
<div class="control-section" style="height: 500px;">
<div id="target" class="control_wrapper">
@Html.UiSplitter(new UiSplitterOptions
{
Id = "outerSplitter", Orientation = UiSplitterOrientation.Vertical, Height = "400px", Width = "100%",
Panes =
{
new UiSplitterPane
{
Size = "53%", Min = "30%",
HtmlContent = Html.UiSplitter(new UiSplitterOptions
{
Id = "innerSplitter", Height = "100%",
Panes =
{
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">HTML</label><div class="code-preview"><pre><!DOCTYPE html>
<html>
<body>
<div id="custom-image">
<img src="src/albert.png" alt="albert">
</div>
</body>
</html></pre></div></div> },
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">CSS</label><div class="code-preview"><pre>img {
margin: 0 auto;
display: flex;
height: 70px;
}</pre></div></div> },
new UiSplitterPane { Template = @<div class="code-editor-content"><label class="h3">JavaScript</label><div class="code-preview"><pre>var image = document.getElementById("custom-image");
image.addEventListener("click", function () {
// Code block for click action
});</pre></div></div> }
}
})
},
new UiSplitterPane { Template = @<div id="splitter2"><h3 class="h3" style="padding: 5px">Preview of sample</h3><div class="splitter-image"><img class="img1" src="@Url.Content("~/Content/splitter/images/albert.png")" alt="albert" style="width: 20%; margin: 0 auto; display: block;" /></div></div> }
}
})
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class SplitterController : Controller
{
// The page is Views/Splitter/CodeEditorLayout.cshtml; it draws what ViewData holds.
public ActionResult CodeEditorLayout()
{
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 Splitter is used to design code editor-like application using multiple panes. In this code editor layout, display HTML, CSS, and JavaScript (JS) code as horizontal panes at the top and output of sample at the bottom pane.