Changing the Title in a Web Form

In ASP.NET, a web form’s title is determined by the HTML View’s Title attribute. However, there is no property in the default (or any other namespace) that helps you to change the title programmatically.

Here’s a simple workaround to accomplish this:

  1. Modify the current </span> tag so that it’s accessible in the code, by adding the <span class="pf"><runat='server'></span> tag.</li> <li> Assign an ID to the <span class="pf"><Title></span> tag. Your code should look like this: <pre><code><title id="pgTitle">Default Title
  2. Add it to the code:
    protected System.Web.UI.HtmlControls.HtmlGenericControl pgTitle;
  3. Change the title in the code, using its InnerText property.
    pgTitle.InnerText = "Changed Text"

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: