Get Page Title and assign that Title to Master page

When we use the master pages, create the Page titles, Meta tag dynamically. But in case when we don't want to manage Page titles, Meta tag dynamically for all pages, then how to assign the page title. We guide you here, how you can get the page title and assign to master page title.

Master page

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="ArticleMaster.master.cs" Inherits="Masterpages_ArticleMaster" %>

<html xmlns="">
<head id="Head1" runat="server">
  <title><asp:Literal id="litBrowserTitle" runat="server"></asp:Literal> </title>

<%@ Page Title="About us" Language="C#" MasterPageFile="~/Masterpages/ArticleMaster.master" AutoEventWireup="true" CodeFile="Aboutus.aspx.cs" Inherits="Aboutus" %>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Aboutus : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        ((Literal)Master.FindControl("litBrowserTitle")).Text = Page.Title;

When you will run the Aboutus.aspx page in browser, then page will render in HTML as:

<html xmlns=""> <head id="Head1"><title>About us</title></head>



Related Alrticles

Add Your Business in Free Listing

FREE!!! Registration