ASP.NET
  Home arrow ASP.NET arrow Page 4 - 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 - The aspx code for the Halloween Store master page


    (Page 4 of 5 )

    Figure 3-4 shows the complete aspx code for the master page in figure 3-1. Although this listing fills the entire page, there’s nothing complex about it. So you shouldn’t have any trouble understanding its elements.

    The banner at the top of the page is displayed using an image control. After the banner, a table element controls the layout of the rest of the page. The first row of this table specifies a height of 400 pixels. It has three cells. The first cell contains a simple navigation menu built using <a> tags. The background color for this cell is set to red. The second cell is a small (10 pixel) spacer cell that gives some space between the navigation menu and the content. And the third cell contains the content placeholder.

    The second row defines the footer that appears at the bottom of the page. It also has three cells, each the same width as the cells in the first row. However, the height of this row is set to 25 pixels. The third cell in this row contains a label control named lblMessage. This label will be used to display the number of days that remain until Halloween.

    The aspx code for the master page (figure 3-4)

    <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
      <title>Murach's ASP.NET 2.0 Upgrader's Guide: Chapter 3 Master Page Application</title>
    </head>
    <body>
     
    <form id="form1" runat="server">
      <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/banner.jpg" /><br />
      <table cellpadding="2" cellspacing="0"<
        <tr height="400">
          <td style="width: 157px" valign="top" bordercolor="red" bgcolor="red">
            <br />
            <a href="Order.aspx">
              <span style="color: #ffffff"><b>Home</b></span>
            </a><br /><br />
            <a href="Cart.aspx">
              <span style="color: #ffffff"><b>Your Shopping Cart</b></span>
            </a><br /><br />
            <a href="Service.aspx">
             
    <span style="color: #ffffff"><b>Customer Service</b></span>
            </a><br /><br />
            <a href="About.aspx">
              <span style="color: #ffffff"><b>About Us</b></span> 
            </a></td> 
          <td style="width: 10px"></td>
          <td style="width: 704px" valign="top">
            <asp:contentplaceholder id="Main" runat="server">
            </asp:contentplaceholder> 
          </td>
        </tr>
        <tr height="25">
          <td bgcolor="red" bordercolor="red" style="width: 153px" valign="top"></td>
          <td style="width: 10px"></td>
          <td style="width: 704px" valign="top">
            <asp:Label ID="lblMessage" runat="server"></asp:Label>
          </td> 
        </tr>
      </table>
      </form>
    </body>
    </html>

    Description

    • Most master pages include elements like banners and navigation controls.
    • It’s common to use tables to provide the layout for the elements on the master page, including the content placeholder.

    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 6 hosted by Hostway
    Stay green...Green IT