Example of Orientation in ASP.NET MVC Tabs Control
This sample demonstrates the header orientation of the Tab. Select option from drop-downs to switch header placement and changing the header style in properties panel.
Anne DodsworthProduct Manager
Laura CallahanTeam Lead
Andrew FullerDeveloper
Robert KingTeam Lead
Michael SuyamaDeveloper
Margaret PeacockDeveloper
Janet LeverlingCEO
Steven BuchananHR
Nancy DavolioProduct Manager
@Html.UiTabs(new UiTabsOptions
{
Id = "orientationTab",
Height = "320px",
ShowCloseButton = true,
Items = new List<UiTabItem>
{
new UiTabItem { Header = "Rome", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["romeData"]) },
new UiTabItem { Header = "Paris", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["parisData"]) },
new UiTabItem { Header = "London", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["londonData"]) }
}
})
@Html.UiDropDownList("orientation", new UiDropDownListOptions { Width = "100%", Value = "Top", Items = ((string[])ViewData["orientationData"]).Select(text => new UiListItem(text, text)).ToList(), OnChange = "changeHeaderPosition" })
@Html.UiDropDownList("headerStyles", new UiDropDownListOptions { Width = "100%", Value = "Default", Items = ((string[])ViewData["styleData"]).Select(text => new UiListItem(text, text)).ToList(), OnChange = "changeHeaderStyle" })
<style>
.e-tab-section, .control-section .e-sample-resize-container { max-width: 760px; margin: 0 auto; padding-top: 20px; }
.e-content .e-item, .ui-tab-panel { font-size: 13px; text-align: justify; }
.property-section .property-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.property-section .property-row > div:first-child { width: 45%; }
.e-content .e-item {
font-size: 12px;
padding: 10px;
text-align: justify;
}
.e-tab .e-list-item {
height: 63px;
border-bottom: 1px solid gainsboro;
}
.e-tab .e-list-item:last-child {
border-bottom: 1px solid gainsboro;
}
.template-container {
height: 100%;
padding-top: 7px;
}
.left {
display: inline-block;
vertical-align: top;
}
.empImg {
height: 48px;
width: 48px;
}
.name, .role {
line-height: normal;
}
.name {
font-weight: 500;
}
.role {
color: grey;
font-weight: 100;
}
.empl-info {
padding: 7px 15px 0 15px;
}
.content-title {
height: 50px;
display: table;
margin: 0 auto;
}
.cnt-text {
vertical-align: middle;
display: table-cell;
font-size: 18px;
font-weight: 600;
}
.e-tab .e-listview .e-header {
height: 50px;
}
.e-tab .e-listview .e-text {
display: block;
text-align: center;
}
.property-panel-content {
padding: 10px;
}
#orientationTab .e-listview:not(.e-list-template) .e-list-item {
height: 63px;
padding: 0 16px !important;
}
#orientationTab .e-tab-text {
display: inherit;
}
.e-vertical-tab .e-content .e-item.e-active,
.e-vertical-tab .e-content .e-item.e-active ul.e-list-parent {
width: 100%;
}
@*custom code start*@
@@media screen and (min-width: 768px) {
.e-sample-resize-container {
width: 75%;
margin: 0 auto;
}
}
@*custom code end*@
@@media screen and (max-width: 481px) {
.control-section.e-tab-section,
.container-fluid,
.e-tab-section .content-wrapper,
.sb-sample-content-area .e-active {
padding-left: 0;
padding-right: 0;
}
}
@@media screen and (max-width: 376px) {
#orientationTab .e-listview:not(.e-list-template) .e-list-item {
padding: 0;
}
.e-sample-resize-container {
padding: 0 5px;
}
.e-tab .e-content.sb-sample-content-area .e-item.e-active {
padding-left: 0;
padding-right: 0;
}
.template-container {
padding: 7px 5px 0;
}
#orientationTab .e-content .e-item.e-active {
padding: 10px 0;
}
.info {
padding: 7px 0 0 8px;
}
}
.emp-list { list-style: none; margin: 0; padding: 0; }
.emp-list .template-container { padding: 7px 10px; border-bottom: 1px solid gainsboro; }
</style>
@using System.Text
@using Lumen.UI.Mvc.Demo.Controllers
@functions {
// Syncfusion fills each tab with a ListView drawn from a template (picture, name and role)
static HtmlString EmployeeList(List<NavigationDemoController.TabEmployee> employees)
{
var html = new StringBuilder("<div class=\"content-title\"><div class=\"cnt-text\">Employee Info</div></div><ul class=\"emp-list\">");
foreach (NavigationDemoController.TabEmployee e in employees)
{
html.Append("<li class=\"template-container\"><div class=\"left\"><img class=\"empImg\" src=\"" + HttpUtility.HtmlAttributeEncode(e.ImgSrc) + "\" alt=\"" + HttpUtility.HtmlAttributeEncode(e.Id) + "\" /></div><div class=\"left empl-info\"><div class=\"name\">" + HttpUtility.HtmlEncode(e.Name) + "</div><div class=\"role\">" + HttpUtility.HtmlEncode(e.Role) + "</div></div></li>");
}
return new HtmlString(html.Append("</ul>").ToString());
}
}
<div class="e-tab-section">
<div class="content-wrapper control-section">
<div class="e-sample-resize-container">
@Html.UiTabs(new UiTabsOptions
{
Id = "orientationTab",
Height = "320px",
ShowCloseButton = true,
Items = new List<UiTabItem>
{
new UiTabItem { Header = "Rome", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["romeData"]) },
new UiTabItem { Header = "Paris", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["parisData"]) },
new UiTabItem { Header = "London", HtmlContent = EmployeeList((List<NavigationDemoController.TabEmployee>)ViewData["londonData"]) }
}
})
</div>
</div>
</div>
<div class="demo-property-panel property-section" title="Properties">
<div class="property-row"><div>Header Placement</div><div>@Html.UiDropDownList("orientation", new UiDropDownListOptions { Width = "100%", Value = "Top", Items = ((string[])ViewData["orientationData"]).Select(text => new UiListItem(text, text)).ToList(), OnChange = "changeHeaderPosition" })</div></div>
<div class="property-row"><div>Header Styles</div><div>@Html.UiDropDownList("headerStyles", new UiDropDownListOptions { Width = "100%", Value = "Default", Items = ((string[])ViewData["styleData"]).Select(text => new UiListItem(text, text)).ToList(), OnChange = "changeHeaderStyle" })</div></div>
</div>
<script>
// Syncfusion: the two lists set headerPlacement and the header style of the Tab
function changeHeaderPosition(value) { if (value) { window.Lumen.get('orientationTab').setHeaderPlacement(value); } }
function changeHeaderStyle(value) { if (value) { window.Lumen.get('orientationTab').setHeaderStyle(value); } }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TabController : Controller
{
// The page is Views/Tab/Orientation.cshtml; it draws what ViewData holds.
// The files under ~/Content are the demo's own sample files: put yours at those paths, or change the addresses.
public ActionResult Orientation()
{
List<TabEmployee> rome = new List<TabEmployee>
{
new TabEmployee { Id = "1", Name = "Anne Dodsworth", Role = "Product Manager", ImgSrc = Url.Content("~/Content/tab/1.png") },
new TabEmployee { Id = "2", Name = "Laura Callahan", Role = "Team Lead", ImgSrc = Url.Content("~/Content/tab/2.png") },
new TabEmployee { Id = "3", Name = "Andrew Fuller", Role = "Developer", ImgSrc = Url.Content("~/Content/tab/3.png") }
};
ViewData["romeData"] = rome;
List<TabEmployee> paris = new List<TabEmployee>
{
new TabEmployee { Id = "4", Name = "Robert King", Role = "Team Lead", ImgSrc = Url.Content("~/Content/tab/4.png") },
new TabEmployee { Id = "5", Name = "Michael Suyama", Role = "Developer", ImgSrc = Url.Content("~/Content/tab/5.png") },
new TabEmployee { Id = "6", Name = "Margaret Peacock", Role = "Developer", ImgSrc = Url.Content("~/Content/tab/6.png") }
};
ViewData["parisData"] = paris;
List<TabEmployee> london = new List<TabEmployee>
{
new TabEmployee { Id = "7", Name = "Janet Leverling", Role = "CEO", ImgSrc = Url.Content("~/Content/tab/7.png") },
new TabEmployee { Id = "8", Name = "Steven Buchanan", Role = "HR", ImgSrc = Url.Content("~/Content/tab/8.png") },
new TabEmployee { Id = "9", Name = "Nancy Davolio", Role = "Product Manager", ImgSrc = Url.Content("~/Content/tab/9.png") }
};
ViewData["londonData"] = london;
ViewData["styleData"] = new string[] { "Default", "Fill", "Accent" };
ViewData["orientationData"] = new string[] { "Top", "Bottom", "Left", "Right" };
return View();
}
/// <summary>A row of the Orientation sample's lists (Syncfusion builds anonymous objects).</summary>
public class TabEmployee
{
public string Id { get; set; }
public string Name { get; set; }
public string Role { get; set; }
public string ImgSrc { get; set; }
}
}
}
@* 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 Tab allows to place the header section inside the Tab component either at top / bottom / left / right position by using headerPlacement property.
This sample illustrates the use of header placement and showCloseButton property. Users can change the header position by changing the drop-down value options and can close the Tab item by clicking close icon in header.
The User can also view different header styles of Tab component by selecting options from `Header Styles` drop-down. Header styles changed by adding predefined classes in Tab root element and it class names listed below
- Material and Fabric theme differentiates all the available tab header styles such as
e-fill,e-background e-accent. - In bootstrap theme, all the styles such as
e-fill&e-background e-accentwill have the same look with no difference.