Quick Reference for creating masterpages 1. Add new master page to project, steps: {Right click SOLUTION}, <add new item>, {select Master Page}, <ADD> 2. New added file’s first line will have directive <%@ Master … 3. Add content page, {select option} “Master Page” while adding. 4. From the list of master pages, select above created master page 5. In the master page there will be tag <asp: ContentPlaceHolder id=”varname” , use this tag to mark content from content page 6. In content page there will be tag <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"… , use this to link content to appropriate place holders in master Master page code sample <body> <form id="form1" runat="server"> <h1>Master Page content</h1> <div> <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </form> </body> </html>
Code page sample <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="contentPage.aspx.cs" Inherits="contentPage" %> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <p> content page content goes here </p> </asp:Content> Note: there is no body tag for content page Screenshots |