Basic structure of Layout Page
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@RenderSection("scripts", required: false)
</body>
</html>
Styles.Render and Scripts.Render
For rendering a bunch of CSS files you can use Style.Render also it is used to create style tag for the CSS. Like Style.Render, Scripts.Render is also used to render a bunches of Script files by rendering script tag for the Script bunches.
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
Sections
A section allow users to specify a region of content within a layout. If user does not provide section then it will throw an exception. The below example code will define a section in a layout page:
@section header{
<h1>Header Content</h1>
}
0 Comment(s)