This documentation is archived and is not being maintained.

HtmlTitle Class

Allows programmatic access to the HTML <title> element on the server.

Namespace:  System.Web.UI.HtmlControls
Assembly:  System.Web (in System.Web.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlTitle : HtmlControl
<asp:HtmlTitle />

Use the HtmlTitle class to programmatically specify the HTML <title> element of a Web Forms page.


You can also set the page title by using the title attribute of the @ Page directive, or by setting the Title property of the Page class.

The following code example demonstrates how to display the current date and time in the title bar of the Web page.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<script runat="server">

  void Page_Load(object sender, EventArgs e)

    if (Page.Header != null)

      Page.Header.Title = "Welcome!  The time is: " + System.DateTime.Now;




<html xmlns="" >

  <head id="Head1" runat="server">
    <title>HtmlTitle Example</title>


    <form id="form1" runat="server">

      <h3>HtmlTitle Example</h3>




Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0