ASP.NET
  Home arrow ASP.NET arrow Page 2 - Master Pages in ASP.Net 2.0
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Master Pages in ASP.Net 2.0
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 15
    2005-09-15

    Table of Contents:
  • Master Pages in ASP.Net 2.0
  • Master Pages – The Concept
  • Content Pages
  • Going Beyond the Basics

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Master Pages in ASP.Net 2.0 - Master Pages – The Concept


    (Page 2 of 4 )

    A Master Page is more or less just a template, or a shell. In the Master Page, you will define the look and feel across your application, as well as the common controls and functionality that is needed (a date, a login indicator, and so forth). It is possible to define multiple master pages within one site/application. For example, you could have one template for your public website, and a completely separate template for the administrative content management system in the backend. You could even have a Master Page nested within another Master Page, but now that’s just crazy!

    A "content" page is the actual page within the site that you’ll be working on, and it will inherit its UI from the Master Page. When the URL of the content page is called, ASP.Net merges the two in the background, and sends the results to the client, who of course will be completely unaware of the fancy process that just took place.

    Master Pages – The Code

    Working with Master Pages will offer a seriously difficult learning curve, as we have an outrageously high number of lines of code to learn and remember. In fact, we are tasked to learn all of two new lines of code.

    1. the first, a new directive, is this:<%@ Master %>
    2. the second, equally as daunting, is this:<asp:contentplaceholder />

    Whew, that was tough! Maybe Microsoft should rethink and create a less complex system…

    Okay, enough sarcasm. It’s actually that easy. In fact, here is all the code necessary to get a barebones Master Page up and running:

    <%@ Master %>
    <html>
    <head>
        <link rel=”Stylesheet” href=”styles.css” />
    </head>
    <body>
          <img src=”logo.gif” />
          <form runat=”server”>
                <asp:contentplaceholder runat=”server”
    id=”bodyContents”>
                      <p>default, replaceable content here</p>
                </asp:contentplaceholder>
          </form>
    </body>
    </html>

    Then you simply save this file with a .master extension, and you’re ready to go! For our example we’ll leave it as the default ‘site.master’.

    Worthy to note is that a Master Page in essence is simply an extended UserControl, so you have all of the same attributes available to the @Master directive as you would with the @Control directive.

    More ASP.NET Articles
    More By Justin Cook


       · Hi Everyone,just a quick note from the author here: hope you enjoy the article,...
     

    ASP.NET ARTICLES

    - More Advanced ASP.NET 3.5 Functions and Subr...
    - ASP.NET 3.5 Functions and Subroutines
    - Coding an IQ Test with Conditionally Driven ...
    - Developing Conditionally Driven Event Handle...
    - ASP.NET 3.5 Debugging Using Visual Web Devel...
    - Understanding Event Handlers in ASP.NET 3.5
    - Building a Web Form in ASP.NET and PHP: a Co...
    - Inserting Data into a Microsoft SQL 2008 Dat...
    - Creating an ASP.NET Dynamic Web Page Using M...
    - Retrieving Data from Microsoft SQL Server 20...
    - Building ASP.NET Web Forms to Use a MySQL Da...
    - Creating an ASP.NET Database using MS SQL 20...
    - Building an ASP.NET Website Using Include Ta...
    - Create ASP.NET Web Forms to Use a Microsoft ...
    - Editing Web Design Layout in Visual Web Deve...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 11 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek