Click to Rate and Give Feedback
MSDN
MSDN Library
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
HtmlTitle Class

Updated: November 2007

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

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

Visual Basic (Declaration)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class HtmlTitle _
    Inherits HtmlControl
Visual Basic (Usage)
Dim instance As HtmlTitle
C#
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlTitle : HtmlControl
Visual C++
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class HtmlTitle : public HtmlControl
J#
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public class HtmlTitle extends HtmlControl
JScript
public class HtmlTitle extends HtmlControl
ASP.NET
<asp:HtmlTitle />

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

Note:

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.

Visual Basic
<%@ Page Language="VB" AutoEventWireup="true"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">


  Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    If (Page.Header IsNot Nothing) Then

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

    End If

  End Sub

</script>

<html  >

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

  <body>

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

      <h3>HtmlTitle Example</h3>

    </form>

  </body>

</html>


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Load(object sender, EventArgs e)
  {

    if (Page.Header != null)
    {

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

    }

  }

</script>

<html  >

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

  <body>

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

      <h3>HtmlTitle Example</h3>

    </form>

  </body>

</html>

System..::.Object
  System.Web.UI..::.Control
    System.Web.UI.HtmlControls..::.HtmlControl
      System.Web.UI.HtmlControls..::.HtmlTitle
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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, 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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker