You may find following snippet very handy in situations where you want to incorporate a base page in a project that uses a master page. From an architectural point of view, implementing a base page is something you should always consider. If you need to implement something in your content pages at a later stage, you only need to do it once, in your base page class. Personally I use it to add meta content and description tags to each content page in my "Web Application Project" site - think SEO!

Refer to Jim Azar's great article for the base page code for adding the meta tags. Note also that you can add your own tags to the the Page attribute of your base class.

In the Page tag of your content page, pay particular attention to the use of the CodeFileBaseClass attribute as this is used to access the public properties of your base page class. This, along with the CodeFile tag, are the new additions to the Page tag for this particular scenario - if you were not using a base page, you wouldn't have these two attributes; instead, you would just have the usual CodeBehind tag.

Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MyProject.master.cs"
    Inherits="MyProject.MasterPages.MyProject" %>

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">   


Base Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MyProject.Master"
    AutoEventWireup="true" CodeBehind="BasePage.aspx.cs"
        Inherits="MyProject.BasePage" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"


Content Page:

<%@ Page Title="MyProject - Home" Language="C#"
    MasterPageFile="~/MasterPages/MyProject.Master" AutoEventWireup="true"
        CodeFileBaseClass="MyProject.BasePage" CodeFile="Default.aspx.cs"
                Meta_Description="Code Snippet: Master Page and Base Page"
                    Meta_Keywords="master, base, content" Theme="Style" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"


kick it on   411ASP.NET