Example of Outlook-style Layout in ASP.NET MVC Splitter Control
This example demonstrates the splitter control that is used to design outlook-like application using multiple horizontal panes. You can resize its panes horizontally to increase dimension.
${text}${Count}
${Text}${Subject}${Preview}
- Favorites
- Sales Reports
- Sent Items
- Marketing Reports
- Andrew Fuller
- Inbox
- Drafts
- Deleted Items
- Sent Items
- Sales Reports
- Marketing Reports
- Outbox
- Junk Email
- RSS Feed
- Trash
- Selma Tally
- Illa Russo
- Camden Macmellon
- Garth Owen
- Ursula Patterson
Subject |
@Html.UiSplitter(new UiSplitterOptions
{
Id = "splitter-outlook", Height = "493px", Width = "100%",
Panes =
{
new UiSplitterPane { Size = "28%", Min = "27%", HtmlContent = Html.UiTreeView(new UiTreeViewOptions { Id = "tree", NodeTemplate = "#treeTemplate", Nodes = (List<UiTreeNode>)ViewData["TemplateFields"] }) },
new UiSplitterPane { Size = "33%", Min = "23%", HtmlContent = Html.UiListView(new UiListViewOptions { Id = "groupedList", Template = "#mailTemplate", Items = (List<UiListItem>)ViewData["ListData"] }) },
new UiSplitterPane
{
Size = "37%", Min = "30%",
Template = @<div class="compose">
<table>
<tr><td>@Html.UiButton(new UiButtonOptions { Id = "toBtn", Text = "To...", Variant = UiButtonVariant.Outline })</td><td>@Html.UiTextBox("firstname")</td></tr>
<tr><td>@Html.UiButton(new UiButtonOptions { Id = "ccBtn", Text = "Cc...", Variant = UiButtonVariant.Outline })</td><td>@Html.UiTextBox("lastname")</td></tr>
<tr><td><div id="subject-text">Subject</div></td><td>@Html.UiTextBox("subject")</td></tr>
</table>
<div class="forum">
@Html.UiRichTextEditor(new UiRichTextEditorOptions { Id = "defaultRTE", Height = "262px" })
<div id="buttonSection">
@Html.UiButton(new UiButtonOptions { Id = "send", Text = "Send", Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "discard", Text = "Discard" })
</div>
</div>
</div>
}
}
})
@Html.UiButton(new UiButtonOptions { Id = "toBtn", Text = "To...", Variant = UiButtonVariant.Outline })
@Html.UiTextBox("firstname")
@Html.UiButton(new UiButtonOptions { Id = "ccBtn", Text = "Cc...", Variant = UiButtonVariant.Outline })
@Html.UiTextBox("lastname")
@Html.UiTextBox("subject")
@Html.UiRichTextEditor(new UiRichTextEditorOptions { Id = "defaultRTE", Height = "262px" })
@Html.UiButton(new UiButtonOptions { Id = "send", Text = "Send", Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "discard", Text = "Discard" })
<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; }
.treeviewdiv { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.treeCount { margin-left: auto; padding: 0 8px; border-radius: 10px; background: var(--ui-accent); color: var(--ui-on-accent); font-size: 12px; line-height: 20px; }
.treeCount:empty { display: none; }
.mail-row { display: grid; padding: 6px 8px; }
.mail-from { font-weight: 600; }
.mail-subject { font-size: 13px; }
.mail-preview { color: var(--ui-muted); font-size: 12px; }
.compose { padding: 15px; }
.compose table { width: 100%; margin-bottom: 8px; }
.compose td { padding: 3px 4px; }
#buttonSection { margin-top: 8px; display: flex; gap: 8px; }
</style>
<template id="treeTemplate"><span class="treeviewdiv"><span class="treeName">${text}</span><span class="treeCount">${Count}</span></span></template>
<template id="mailTemplate"><div class="mail-row"><span class="mail-from">${Text}</span><span class="mail-subject">${Subject}</span><span class="mail-preview">${Preview}</span></div></template>
<div class="control-section" style="height: 580px;">
<div id="target">
@Html.UiSplitter(new UiSplitterOptions
{
Id = "splitter-outlook", Height = "493px", Width = "100%",
Panes =
{
new UiSplitterPane { Size = "28%", Min = "27%", HtmlContent = Html.UiTreeView(new UiTreeViewOptions { Id = "tree", NodeTemplate = "#treeTemplate", Nodes = (List<UiTreeNode>)ViewData["TemplateFields"] }) },
new UiSplitterPane { Size = "33%", Min = "23%", HtmlContent = Html.UiListView(new UiListViewOptions { Id = "groupedList", Template = "#mailTemplate", Items = (List<UiListItem>)ViewData["ListData"] }) },
new UiSplitterPane
{
Size = "37%", Min = "30%",
Template = @<div class="compose">
<table>
<tr><td>@Html.UiButton(new UiButtonOptions { Id = "toBtn", Text = "To...", Variant = UiButtonVariant.Outline })</td><td>@Html.UiTextBox("firstname")</td></tr>
<tr><td>@Html.UiButton(new UiButtonOptions { Id = "ccBtn", Text = "Cc...", Variant = UiButtonVariant.Outline })</td><td>@Html.UiTextBox("lastname")</td></tr>
<tr><td><div id="subject-text">Subject</div></td><td>@Html.UiTextBox("subject")</td></tr>
</table>
<div class="forum">
@Html.UiRichTextEditor(new UiRichTextEditorOptions { Id = "defaultRTE", Height = "262px" })
<div id="buttonSection">
@Html.UiButton(new UiButtonOptions { Id = "send", Text = "Send", Color = UiButtonColor.Primary })
@Html.UiButton(new UiButtonOptions { Id = "discard", Text = "Discard" })
</div>
</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/OutlookStyleLayout.cshtml; it draws what ViewData holds.
public ActionResult OutlookStyleLayout()
{
ViewData["TemplateFields"] = new List<UiTreeNode>
{
new UiTreeNode { Id = "1", Text = "Favorites", Children =
{
new UiTreeNode { Id = "2", Text = "Sales Reports", Data = new { Count = "4" } },
new UiTreeNode { Id = "3", Text = "Sent Items" },
new UiTreeNode { Id = "4", Text = "Marketing Reports", Data = new { Count = "6" } }
} },
new UiTreeNode { Id = "5", Text = "Andrew Fuller", Expanded = true, Children =
{
new UiTreeNode { Id = "6", Text = "Inbox", Selected = true, Data = new { Count = "20" } },
new UiTreeNode { Id = "7", Text = "Drafts", Data = new { Count = "5" } },
new UiTreeNode { Id = "8", Text = "Deleted Items" },
new UiTreeNode { Id = "9", Text = "Sent Items" },
new UiTreeNode { Id = "10", Text = "Sales Reports", Data = new { Count = "4" } },
new UiTreeNode { Id = "11", Text = "Marketing Reports", Data = new { Count = "6" } },
new UiTreeNode { Id = "12", Text = "Outbox" },
new UiTreeNode { Id = "13", Text = "Junk Email" },
new UiTreeNode { Id = "14", Text = "RSS Feed" },
new UiTreeNode { Id = "15", Text = "Trash" }
} }
};
ViewData["ListData"] = new List<UiListItem>
{
new UiListItem { Value = "1", Text = "Selma Tally", Data = new { Subject = "Apology marketing email", Preview = "Hello Ananya Singleton" } },
new UiListItem { Value = "4", Text = "Illa Russo", Data = new { Subject = "Annual conference", Preview = "Hi jeani Moresa" } },
new UiListItem { Value = "3", Text = "Camden Macmellon", Data = new { Subject = "Reference request- Camden hester", Preview = "Hello Kerry Best" } },
new UiListItem { Value = "2", Text = "Garth Owen", Data = new { Subject = "Application for job Title", Preview = "Hello Illa Russo" } },
new UiListItem { Value = "5", Text = "Ursula Patterson", Data = new { Subject = "Programmaer Position Applicant", Preview = "Hello Kerry best" } }
};
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 control is used to create outlook-like user interface application using multiple panes with horizontal orientation. To create outlook-style user interface, use TreeView, ListView, and Rich Text Editor controls within split panes. The TreeView control is used to display mail folders at left pane and ListView to display details of mail items, and Rich Text Editor to create new mail.