ASP.NET
  Home arrow ASP.NET arrow Page 2 - How to Use Master Pages
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

How to Use Master Pages
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 16
    2005-12-01

    Table of Contents:
  • How to Use Master Pages
  • How to create a master page
  • The aspx code for a new master page
  • The aspx code for the Halloween Store master page
  • The code-behind file for the master page

  • 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


    How to Use Master Pages - How to create a master page


    (Page 2 of 5 )

    As figure 3-2 shows, you create a master page by using the Website->Add New Item command. Master Page is listed as one of the templates in the Add New Item dialog box. Select this template, select Visual Basic as the language, and click Add to create the master page. The default name for a master page is MasterPage.master.

    The master page created from the template includes a ContentPlaceHolder control that will contain the content page, but nothing else. You’ll learn more about the ContentPlaceHolder control in the next figure. For now, just realize that it marks the location on the rendered page where the content from the content page will be displayed.

    You can develop the master page by adding elements outside of the ContentPlaceHolder control. For example, to create the master page in figure 3-1, you add an image for a banner above the placeholder, navigation links to the left of the placeholder, and a label to display the days remaining until Halloween below the placeholder. Typically, you’ll use an HTML table to specify the layout of these elements.

    Note that an application can contain more than one master page. This allows you to create an application that has two or more sections with distinct page layouts. For example, you may want to use one master page for all of the content pages in the online shopping section of a web site, and another master page for the content pages in the customer service section.

    In addition, you should realize that a master page can have more than one content placeholder. This lets you create a page layout that has custom content in two or more different areas of the page. To create an additional content placeholder, you simply drag the ContentPlaceHolder control from the Standard tab of the Toolbox onto the master page and give it a unique ID.

    A new master page in Design view (figure 3-2)
     

    Description

    • To add a master page to a project, choose the Website->Add New Item command. Then, in the Add New Item dialog box, select Master Page from the list of templates, specify the name of the master page you want to create in the Name text box (the default is Master Page.master), and select the programming language. Then, click Add.
    • The content placeholder appears as a control in the Web Forms Designer. Although you can change the position of the content placeholder, you can’t edit its contents from the master page. Instead, you add content to the master page by creating content pages as described later in this chapter.
    • Any elements you add to the master page outside of the content placeholder will appear on every content page that uses the master page.
    • Although most master pages have just one content placeholder, you can create more than one content placeholder if you need to. In that case, each placeholder displays a portion of the content of each content page.
    • An application can have more than one master page, and each content page specifies which master page should be used to display the content page.
    • The aspx file for a master page uses the extension .master. The code-behind file uses .master.vb.

    More ASP.NET Articles
    More By Murach Publishing


       · This article is an excerpt from the book "Murach’s ASP.NET 2.0 Upgrader’s Guide: VB...
       · I would love to read the article if the sample images weren't dead links. I'm not...
       · Hi,I like the article on Master pages. I want to ask one question whether I can...
     

    Buy this book now. This article is excerpted from chapter three of the book Murach’s ASP.NET 2.0 Upgrader’s Guide: VB Edition, written by Anne Boehm and Joel Murach (Murach, 2005; ISBN: 1-890774-36-7). Check it out today at your favorite bookstore. Buy this book now.

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT