Creating Master Page (MasterPage in Web.config) in ASP.NET: Part 5

We can apply a Master Page to every content page in a particular folder or every content page in an entire application. Rather than add a MasterPageFile attribute to individual content pages, we can add a configuration option to the web configuration file.

For example

The web configuration file given below applies the SimpleMaster.master Master Page to every page contained in the same folder (or subfolder) as the web configuration file.

<?xml version="1.0"?>
pages masterPageFile="~/MasterPage.master" />


The Above Master Page given in the Web.config file is applied only to content pages. If a page does not contain any Content controls and it is a normal ASP.NET page then the Master Page is ignored. We can override the Master Page configured in the web configuration file in the case of a particular content page. In other words, a MasterPageFile attribute in a content page takes precedence over a Master Page specified in the web configuration file.

Note: This is last part of this series of articles.

Up Next
    Ebook Download
    View all
    View all