Programmatically Setting a Page’s Title

I recently needed to change the Title of an Application Page in SharePoint 2010 from code behind. This is how I did it in Page_Load...

So the sequence goes:

  1. Get a reference to the appropriate Content Placeholder
  2. Clear out anything that SharePoint might have put in it already
  3. Put your content in.

Or, in C#:

ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder) Page.Master.FindControl("PlaceHolderPageTitle");

contentPlaceHolder.Controls.Clear();

LiteralControl literalControl = new LiteralControl();

literalControl.Text = "Your text goes here";

contentPlaceHolder.Controls.Add(literalControl);

Add comment

Loading