Login.TitleText 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定控制權的名稱 Login 。
public:
virtual property System::String ^ TitleText { System::String ^ get(); void set(System::String ^ value); };
public virtual string TitleText { get; set; }
member this.TitleText : string with get, set
Public Overridable Property TitleText As String
屬性值
控制權的標題 Login 。 預設是「登入」。
範例
以下程式碼範例設定了屬性 TitleText 。
這很重要
此範例包含一個接受使用者輸入的文字框,這可能構成安全威脅。 預設情況下,ASP.NET 網頁會驗證使用者輸入中不包含腳本或 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 changeClick(object sender, EventArgs e)
{
Login1.TitleText = newTitle.Text;
}
void OnLoginError(object sender, EventArgs e)
{
Login1.TitleTextStyle.BackColor = System.Drawing.Color.Red;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<table style="text-align:center; border:1">
<tr>
<td>
Title Text:
</td>
<td>
<asp:TextBox id="newTitle" runat="server">Login</asp:TextBox></td>
<td>
<asp:Button id="change" runat="server" onClick="changeClick" Text="Change"></asp:Button></td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Login id="Login1" runat="server"
TitleText="Log In Now"
OnLoginError="OnLoginError">
<TitleTextStyle
Font-Bold="True"
ForeColor="#0000C0"
BackColor="#E0E0E0">
</TitleTextStyle>
</asp:Login>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub changeClick(ByVal sender As Object, ByVal e As EventArgs)
Login1.TitleText = newTitle.Text
End Sub
Sub OnLoginError(ByVal sender As Object, ByVal e As EventArgs)
Login1.TitleTextStyle.BackColor = System.Drawing.Color.Red
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<table style="text-align:center; border:1">
<tr>
<td>
Title Text:
</td>
<td>
<asp:TextBox id="newTitle" runat="server">Login</asp:TextBox></td>
<td>
<asp:Button id="change" runat="server" onClick="changeClick" Text="Change"></asp:Button></td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Login id="Login1" runat="server"
TitleText="Log In Now"
OnLoginError="OnLoginError">
<TitleTextStyle
Font-Bold="True"
ForeColor="#0000C0"
BackColor="#E0E0E0">
</TitleTextStyle>
</asp:Login>
</td>
</tr>
</table>
</form>
</body>
</html>
備註
TitleText屬性指定了在控制件頂部Login顯示的標題。
控制項的預設文字會根據伺服器目前所在地而在地化。
設定後,該屬性的值可透過設計工具自動儲存到資源檔案中。 欲了解更多資訊,請參閱LocalizableAttribute全球化與在地化。