Inline Code - Create a Masterpage Template

Follow

A layout file includes your HTML declaration, head, and body as well as links to any JavaScript or CSS files. Page Templates in Agility will default to using the standard "_Layout.cshtml" file in your MVC Application, however it you'd like Agility Page Templates to use an Inline Code file as the Masterpage, you'll need to create a Template to function as your Masterpage.

  1. Create a new Template in Inline Code (see Inline Code - Create a Template)

  2. Scaffold your HTML to include the following important Agility Placeholders:

    <!doctype html>
    <html>
        <head>
            <meta name="viewport" content="width-device, initial-scale=1.0">
    
            <!-- Use the Agility Page's Title as the document title -->
            <title>@ViewBag.Title</title>
    
            <!-- Agility Placeholders, to output top scripts,
                meta tags/keywords/description and additional header markup -->
            @{Html.RenderAgilityTopScripts();}
            @{Html.RenderAgilityCSSOnly();}
    
        </head>
        <body>
            <!-- Reference another Inline Code Template for the Header -->
            @Html.AgilityTemplate("Header")
    
            <!-- Instruct the MVC Application to load your Page Template here -->
            @RenderBody()
    
    	<!-- Agility Placeholders, to output bottom scripts -->
            @{Html.RenderAgilityScriptsNoJQuery();}
    
        </body>
    </html>
  3.  Optionally, reference other files you have in Inline Code using the following format:

    <!-- Reference other Inline Code CSS Files -->
    @Html.AgilityCSS("boostrap")
    
    <!-- Reference another Inline Code Template for the Header -->
    @Html.AgilityTemplate("Header")
    
    <!-- Reference another Inline Code JS file -->
    @Html.AgilityJavascript("defaultscript")
  4. Next, you'll need to set this as your Masterpage layout file for any of your relevant Page Templates. These Page Templates can exist in Inline Code or within code in the MVC project. At the top of the file add the following line of code:

    @{ Layout = Html.AgilityTemplatePath("Masterpage"); }
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.