Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Layouts, RenderBody, RenderSection and RenderPage in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 102
    Comment on it

    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>
        }
    
    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: