Presentation is loading. Please wait.

Presentation is loading. Please wait.

Working with ASP.NET Master Pages.

Similar presentations


Presentation on theme: "Working with ASP.NET Master Pages."— Presentation transcript:

1 Working with ASP.NET Master Pages

2 Two of the most interesting concepts are master pages and themes.
In some respects, master pages and themes accomplish similar goals—they both create a general look for a Web site. However, a master page and a theme differ in their approach to the Web development problem. The idea behind these technologies is to help the developer in creating pages faster by reducing the need to repeat the elements that appear on every page & reducing the update time.

3 Understanding Master Pages
A master page is a new way of organizing a Web site. It can contain a combination of formatting, graphics, and layout—whatever elements you feel that are common to all Web pages on your site content. The idea is to give your Web site a consistent look and reduce the workload on developers. A master page always has a MASTER file extension. A master page is always an organization tool for other Web pages; no one actually sees it online. it contains a special tag that identifies it as a master page to the Web server.

4 a master page contains ContentPlaceHolder controls that tell someone using the master page where to add the unique information for the Web page. When the server sees the MasterPageFile attribute, it reads the information found in the associated MASTER file before it reads the content from the ASPX page. It uses the MASTER file content to build a framework for the ASPX page and then places the unique ASPX page content within the framework.

5 Of course, this brings the question of how the server knows where to place the information. The ASPX page contains special container tags that hold the content which the MASTER file describes, such as this one: <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1“ Runat="Server">

6 Creating the Master Page
The easiest way to add a master page to the Web site is to open Solution Explorer. Right-click the project entry and choose Add New Item from the context menu. Select Master Page option. Select a language for the master page you want to create. Click Add to add the master page to the project. Master pages always must have one content area as a minimum.

7 Creating a Project with Master Pages
Once you have a master page defined, you can use it to create content pages. A content page has the content and organization provided by the master page, plus unique content that the individual page provides. You can use master pages to create content pages in a number of ways. The following sections explore the techniques that you’ll commonly use.

8 Creating a Content Page Using a Master Page
Adding content pages doesn’t have to be slow or time consuming. The easiest method for creating a content page based on master page is to: open the master page. right-click anywhere on the form in Design view. choose Add Content Page from the context menu. The IDE creates a new content page that uses default settings and a generic name based on the master page.

9 Another way to create a content page using a master page is to:
right-click the project entry in Solution Explorer. Choose Add New Item from the context menu. you’ll see the Add New Item dialog box. Select Web Form option. choose a programming language. type a name for the file. Click Select Master Page option in this dialog box. Click Add.


Download ppt "Working with ASP.NET Master Pages."

Similar presentations


Ads by Google