Blog from Saravanan Arumugam

Let us talk about Technologies

Changing titles in master page based web sites

We are aware that the <header> and <body> tags are contained in the Master page. Only the contents come in content pages.

One question that might arise is that how would the title change along with the change in content pages?

One workaround to do it is, provide a <ContentPlaceHolder> control inside the header of the master page. In the content page write the <title> tag.

Master page content would look like this.

<head runat=”server”>

<link href=”~/Styles/Site.css” rel=”stylesheet” type=”text/css” />

<asp:ContentPlaceHolder ID=”HeadContent” runat=”server”>



Content page would look like this.

<asp:Content ID=”HeaderContent” runat=”server” ContentPlaceHolderID=”HeadContent”>

<title>Title from the content page</title>


While running the application, you can see the “Title from the content page” in the content page.

Well, this is just a work around. There is a clear and straight solution provided by ASP.Net for this.

To change the title, use the title property of page directives (in the content pages).

<%@ Page Language=”C#” Title=”Title from the content page” MasterPageFile=”~/Site.master” AutoEventWireup=”true”

CodeBehind=”DataEntry.aspx.cs” Inherits=”MasterPageExploration._Default” %>

When the Asp.Net sees the title property, it renders it for your page.

Well, the next question.

What would happen if the <title> element is found in the master page itself? Is it legal to have it in the master/content page and provide the title element on the page directive?


Here is the hierarchy of search, where the first holds the least priority and the last box holds the top priority.


However it is ideal/advised to keep the title element in the master page blank (or with a default site name), and provide the dynamic titles in each content page in the title property of the page directive.


One response to “Changing titles in master page based web sites

  1. Hebergement Maroc January 4, 2012 at 3:15 pm


    interresting, post here may come back soon
    continue updating your blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: