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
Dim instance As HtmlTitle
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HtmlTitle : HtmlControl
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class HtmlTitle : public HtmlControl
public class HtmlTitle extends HtmlControl
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.
<%@ 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>
<%@ 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 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
Reference