_ViewStart.cshtml
file.
We have included styles and scripts files in Common Master Layout. You can find these files at the same path inside Views/Shared/
folder.
@{
@* using this variables to load front pages assets *@
bool isFront = ViewData["isFront"] is bool isFrontValue ? isFrontValue : false;
ViewData["main"] = isFront ? "front-" : "";
ViewData["frontVar"] = isFront ? "Front" : "";
@* Compact/Fluid class *@
ViewData["contentType"] = ViewData["container"] is string container && container == "container-xxl" ? "layout-compact" : "layout-wide";
}
@await Html.PartialAsync("Sections/_Variables")
@inject IHttpContextAccessor httpContextAccessor
<!DOCTYPE html>
<html lang="en"
class='light-style @(ViewData["navbarType"] is string navbarType ? navbarType : "") @(ViewData["menuFixed"] is string menuFixed ? menuFixed : "") @(ViewData["menuCollapsed"] is string menuCollapsed ? menuCollapsed : "") @(ViewData["contentType"] is string contentType ? contentType : "") @(ViewData["footerFixed"] is string footerFixed ? footerFixed : "") @(ViewData["customizerHidden"] is string customizerHidden ? customizerHidden : "")'
dir="ltr" data-theme="theme-default" data-assets-path='@((httpContextAccessor.HttpContext?.Request.PathBase ?? "") + "/")'
data-template='@(isFront ? "front-page" : (Convert.ToBoolean(TempData.Peek("menuHorizontal")?.ToString()) ? "horizontal-menu-template" : "vertical-menu-template"))'>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
@{
string title = ViewData["title"] as string ?? "";
string appName = TempData.Peek("appName") as string ?? "";
string productPage = TempData.Peek("productPage") as string ?? "";
}
<title>@title | @appName - Asp.Net Core MVC Admin Template</title>
<meta name="description" content="" />
<!-- Canonical SEO -->
<link rel="canonical" href='@productPage'>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="~/img/favicon/favicon.ico" />
<!-- Core Styles -->
@await Html.PartialAsync("Sections/_Styles" + ViewData["frontVar"])
<!-- Vendor Styles -->
@RenderSection("VendorStyles", required: false)
<!-- Page Styles -->
@RenderSection("PageStyles", required: false)
<!-- Include Scripts for customizer, helper, analytics, config -->
@await Html.PartialAsync("Sections/_ScriptsIncludes" + ViewData["frontVar"])
</head>
<body>
<!-- Layout Content -->
@RenderBody()
<!--/ Layout Content -->
<!-- Core Scripts -->
@await Html.PartialAsync("Sections/_Scripts" + ViewData["frontVar"])
<!-- Vendor Scripts -->
@RenderSection("VendorScripts", required: false)
<script src='~/js/@ViewData["main"]main.js'></script>
<!-- Page Scripts-->
@RenderSection("PageScripts", required: false)
</body>
</html>
Included variable file contains all the required variables through out the application.
appName
and appURL
variables, you can easily change the application name and URL in the whole application.
You can find this file at Views/Shared/Sections/_Variables.cshtml
@{
TempData["appName"] = "Materialize";
TempData["appUrl"] = "https://pixinvent.com/materialize-material-design-bootstrap-admin-template/";
@* Footer & Misc urls *@
TempData["authorName"] = "Pixinvent";
TempData["authorUrl"] = "https://pixinvent.com/";
TempData["licenseUrl"] = "https://themeforest.net/licenses/standard";
TempData["productPage"] = "https://1.envato.market/materialize_admin";
TempData["support"] = "https://pixinvent.ticksy.com/";
TempData["documentation"] ="https://demos.pixinvent.com/materialize-html-admin-template/documentation/net-core-mvc-introduction.html";
TempData["twitterUrl"] = "https://twitter.com/pixinvents";
TempData["instagramUrl"] = "https://www.instagram.com/pixinvents/";
TempData["facebookUrl"] = "https://www.facebook.com/pixinvents/";
TempData["githubUrl"] = "https://github.com/pixinvent";
TempData["dribbbleUrl"] = "https://dribbble.com/pixinvent";
}
Included styles file contains all the core css, theme css, demo css and more..
You can find this file at Views/Shared/Sections/_Styles.cshtml
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<environment include="Development">
<!-- Fonts & Flag icons -->
<link rel="stylesheet" href="~/vendor/fonts/remixicon/remixicon.css" />
<link rel="stylesheet" href="~/vendor/fonts/flag-icons.css" />
<link rel="stylesheet" href="~/vendor/libs/node-waves/node-waves.css" />
<!-- Core CSS -->
<link rel="stylesheet" href="~/vendor/css/core.css" class="template-customizer-core-css" />
<link rel="stylesheet" href="~/vendor/css/theme-default.css" class="template-customizer-theme-css" />
<link rel="stylesheet" href="~/css/demo.css" />
<!-- `perfect-scrollbar` library required by SideNav plugin, `typeahead` required by search -->
<link rel="stylesheet" href="~/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
<link rel="stylesheet" href="~/vendor/libs/typeahead-js/typeahead.css" />
<!-- Application stylesheets -->
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<!-- Fonts & Flag icons -->
<link rel="stylesheet" href="~/vendor/fonts/remixicon/remixicon.css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/fonts/flag-icons.css" asp-append-version="true" />
<!-- Core CSS -->
<link rel="stylesheet" href="~/vendor/css/core.css" class="template-customizer-core-css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/css/theme-default.css" class="template-customizer-theme-css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/demo.css" />
<!-- `perfect-scrollbar` library required by SideNav plugin, `typeahead` required by search -->
<link rel="stylesheet" href="~/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/libs/node-waves/node-waves.css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/libs/typeahead-js/typeahead.css" asp-append-version="true" />
<!-- Application stylesheets -->
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</environment>
This file includes helpers, customization, config js along with templateCustomizer initialization script :
You can find this file at Views/Shared/Sections/_ScriptsIncludes.cshtml
<environment include="Development">
@* Template helper js *@
<script src="~/vendor/js/helpers.js"></script>
@* Template customizer js *@
<script src="~/vendor/js/template-customizer.js"></script>
@* Config file contain global vars & default theme options, Set your preferred theme option in this file. *@
<script src="~/js/config.js"></script>
</environment>
<environment exclude="Development">
<script src="~/vendor/js/helpers.js" asp-append-version="true"></script>
<script src="~/vendor/js/template-customizer.js" asp-append-version="true"></script>
<script src="~/js/config.js" asp-append-version="true"></script>
</environment>
This file includes main js along with template related vendor scripts :
You can find this file at Views/Shared/Sections/_Scripts.cshtml
<environment include="Development">
<script src="~/vendor/libs/jquery/jquery.js"></script>
<script src="~/vendor/libs/popper/popper.js"></script>
<script src="~/vendor/js/bootstrap.js"></script>
<!-- `perfect-scrollbar` library required by SideNav plugin -->
<script src="~/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<!-- `hammer` required for swipe guesture -->
<script src="~/vendor/libs/hammer/hammer.js"></script>
<!-- `i18n` required for translation -->
<script src="~/vendor/libs/i18n/i18n.js"></script>
<!-- `typeahead` required for search fn -->
<script src="~/vendor/libs/typeahead-js/typeahead.js"></script>
<script src="~/vendor/libs/feather-icons/feather.js"></script>
<!-- `typeahead` required for sideNav -->
<script src="~/vendor/js/menu.js"></script>
<script src="~/js/site.js"></script>
</environment>
<environment exclude="Development">
<script src="~/vendor/libs/jquery/jquery.js" asp-append-version="true"></script>
<script src="~/vendor/libs/popper/popper.js" asp-append-version="true"></script>
<script src="~/vendor/js/bootstrap.js" asp-append-version="true"></script>
<script src="~/vendor/libs/perfect-scrollbar/perfect-scrollbar.js" asp-append-version="true"></script>
<script src="~/vendor/libs/hammer/hammer.js" asp-append-version="true"></script>
<script src="~/vendor/libs/i18n/i18n.js" asp-append-version="true"></script>
<script src="~/vendor/libs/typeahead-js/typeahead.js" asp-append-version="true"></script>
<script src="~/vendor/libs/feather-icons/feather.js" asp-append-version="true"></script>
<script src="~/vendor/js/menu.js" asp-append-version="true"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
Included styles file contains all the core css, theme css, demo css and more..
You can find this file at Views/Shared/Sections/_StylesFront.cshtml
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<environment include="Development">
<!-- Fonts & Flag icons -->
<link rel="stylesheet" href="~/vendor/fonts/remixicon/remixicon.css" />
<!-- Core CSS -->
<link rel="stylesheet" href="~/vendor/css/core.css" class="template-customizer-core-css" />
<link rel="stylesheet" href="~/vendor/css/theme-default.css" class="template-customizer-theme-css" />
<link rel="stylesheet" href="~/css/demo.css" />
<link rel="stylesheet" href="~/vendor/libs/node-waves/node-waves.css" />
<link rel="stylesheet" href="~/vendor/css/pages/front-page.css" />
<!-- Application stylesheets -->
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment exclude="Development">
<!-- Fonts & Flag icons -->
<link rel="stylesheet" href="~/vendor/fonts/remixicon/remixicon.css" asp-append-version="true" />
<!-- Core CSS -->
<link rel="stylesheet" href="~/vendor/css/core.css" class="template-customizer-core-css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/css/theme-default.css" class="template-customizer-theme-css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/demo.css" />
<link rel="stylesheet" href="~/vendor/libs/node-waves/node-waves.css" asp-append-version="true" />
<link rel="stylesheet" href="~/vendor/css/pages/front-page.css" asp-append-version="true" />
<!-- Application stylesheets -->
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
</environment>
This file includes helpers, customization, config js along with templateCustomizer initialization script :
You can find this file at Views/Shared/Sections/_ScriptsIncludesFront.cshtml
<environment include="Development">
@* Template helper js *@
<script src="~/vendor/js/helpers.js"></script>
@* Template customizer js *@
<script src="~/vendor/js/template-customizer.js"></script>
@* Config file contain global vars & default theme options, Set your preferred theme option in this file. *@
<script src='~/js/front-config.js'></script>
<script src="~/vendor/js/dropdown-hover.js"></script>
<script src="~/vendor/js/mega-dropdown.js"></script>
</environment>
<environment exclude="Development">
<script src="~/vendor/js/helpers.js" asp-append-version="true"></script>
<script src="~/vendor/js/template-customizer.js" asp-append-version="true"></script>
<script src='~/js/front-config.js' asp-append-version="true"></script>
<script src="~/vendor/js/dropdown-hover.js" asp-append-version="true"></script>
<script src="~/vendor/js/mega-dropdown.js" asp-append-version="true"></script>
</environment>
This file includes main js along with template related vendor scripts :
You can find this file at Views/Shared/Sections/_ScriptsFront.cshtml
<environment include="Development">
<script src="~/vendor/libs/popper/popper.js"></script>
<script src="~/vendor/js/bootstrap.js"></script>
<script src="~/vendor/libs/node-waves/node-waves.js"></script>
<script src="~/js/site.js"></script>
</environment>
<environment exclude="Development">
<script src="~/vendor/libs/popper/popper.js" asp-append-version="true"></script>
<script src="~/vendor/js/bootstrap.js" asp-append-version="true"></script>
<script src="~/vendor/libs/node-waves/node-waves.js" asp-append-version="true"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
You can set the layout in two ways:
Layout
property in the Views/_ViewStart.cshtml
file.Layout
property in the .cshtml
file.For ex. We have added custom options in LayoutExample pages
You can find Navbar, Sidebar and Footer templates in the Views/Shared/Sections
directory.
@{
Layout = "_ContentNavbarLayout";
}
@{
Layout = "_ContentNavbarLayout";
ViewData["isFlex"] = (ViewData["isFlex"] ??= true);
}
<div class="flex-shrink-1 flex-grow-0 w-px-350 border-end container-p-x container-p-y">
<div class="layout-example-sidebar layout-example-content-inner">
Sidebar
</div>
</div>
<div class="flex-shrink-1 flex-grow-1 container-p-x container-p-y">
<!-- Layout Demo -->
<div class="layout-demo-wrapper">
<h4>Layout content navbar + sidebar</h4>
<p>Container layout sets a <code>max-width</code> at each responsive breakpoint.</p>
</div>
<!--/ Layout Demo -->
</div>
@{
Layout = "_HorizontalLayout";
}
@{
Layout = "_ContentNavbarLayout";
ViewData["navbarHideToggle"] = true;
ViewData["isMenu"] = false;
}
@{
Layout = "_ContentNavbarLayout";
ViewData["isNavbar"] = false;
}
@{
Layout = "_ContentNavbarLayout";
ViewData["container"] = (ViewData["container"] ?? "container-fluid");
ViewData["containerNav"] = (ViewData["containerNav"] ?? "container-fluid");
}
@{
Layout = "_ContentNavbarLayout";
}
Layout options are useful to create layout with custom options as per different layout examples. You can add this options at page level or layout level as well.
Find all the layout options with it's value below :
Data Options | DataType | Data Values |
---|---|---|
TempData["menuHorizontal"] |
Boolean | true | false |
ViewData["container"] |
String | "container-fluid" | "container-xxl" |
ViewData["containerNav"] |
String | "container-fluid" | "container-xxl" |
ViewData["customizerHidden"] |
String | "customizer-hide" |
ViewData["footerFixed"] |
String | "layout-footer-fixed" |
ViewData["menuCollapsed"] |
String | "layout-menu-collapsed" |
ViewData["menuFixed"] |
String | "layout-menu-fixed" |
ViewData["navbarType"] |
String | "layout-navbar-fixed" |
ViewData["contentNavbar"] |
Boolean | true | false |
ViewData["isFlex"] |
Boolean | true | false |
ViewData["isMenu"] |
Boolean | true | false |
ViewData["isNavbar"] |
Boolean | true | false |
ViewData["navbarFull"] |
Boolean | true | false |
ViewData["navbarHideToggle"] |
Boolean | true | false |
ViewData["isFront"] |
Boolean | true | false |
ViewData["contentType"] |
String | "container-fluid" | "container-xxl" |
To set default layout to dark layout, just need to update wwwroot\js\config.js
file's defaultStyle
option :
if (typeof TemplateCustomizer !== 'undefined') {
window.templateCustomizer = new TemplateCustomizer({
...
defaultStyle: 'dark',
...
});
}
wwwroot\js\
folder.
To set default layout to RTL layout, just need to update wwwroot\js\config.js
file's defaultTextDir
option :
if (typeof TemplateCustomizer !== 'undefined') {
window.templateCustomizer = new TemplateCustomizer({
...
defaultTextDir: 'rtl',
...
});
}
wwwroot\js\
folder.