HtmlTitle.Text Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the text of the HTML <title>
element.
public:
virtual property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty)]
public virtual string Text { get; set; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty)>]
member this.Text : string with get, set
Public Overridable Property Text As String
Property Value
The text of the HTML <title>
element. The default value is an empty string ("").
- Attributes
Examples
The following code example demonstrates using the Text property of an HtmlTitle control to dynamically change the title of a Web page.
<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
<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="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 xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>HtmlTitle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>HtmlTitle Example</h3>
</form>
</body>
</html>
Remarks
Use the Text property to specify or determine the title of the Web page.
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET