How to Change Application Page Title Dynamically In C# Code Behind



TODO:

Have you ever wanted to change the title of your Application Page dynamically?

 

SOLUTIONS:

protected void SetPageTitles(string Title)
{
     ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)Page.Master.FindControl("PlaceHolderPageTitle");
     contentPlaceHolder.Controls.Clear();
     LiteralControl title = new LiteralControl();
     title.Text = Title;
     contentPlaceHolder.Controls.Add(title);

     contentPlaceHolder = (ContentPlaceHolder)Page.Master.FindControl("PlaceHolderPageTitleInTitleArea");
     contentPlaceHolder.Controls.Clear();
     title = new LiteralControl();
     title.Text = Title;
     contentPlaceHolder.Controls.Add(title);
}

 

NOTES:

There are no notes on this topic.