how to change title of aspx page dynamically on page load

Randhi Rupesh picture Randhi Rupesh · Jun 7, 2013 · Viewed 44k times · Source

I had set of ASPX pages in which each page had different titles, but I want to put default title for pages which don't have a title. The default title must be configurable.

Answer

gzaxx picture gzaxx · Jun 7, 2013

If this is classic ASP.NET (not MVC) and you are using MasterPage then you can set default title in Page_Load event in MasterPage:

protected void Page_Load(object sender, EventArgs e)
{
      if (string.IsNullOrEmpty(Page.Title))
      {
           Page.Title = ConfigurationManager.AppSettings["DefaultTitle"];  //title saved in web.config
      }
}