Login.TitleTextStyle 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得定義 Login 控制項中標題文字外觀之屬性集合的參考。
public:
property System::Web::UI::WebControls::TableItemStyle ^ TitleTextStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle TitleTextStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.TitleTextStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property TitleTextStyle As TableItemStyle
屬性值
TableItemStyle 的參考,包含定義標題文字外觀的屬性。
- 屬性
範例
下列程式碼範例會藉由設定 屬性所參考 TitleTextStyle 物件的屬性 TableItemStyle ,來設定標題的文字色彩、背景色彩和字型粗細。
重要
此範例包含一個文字方塊,可接受使用者輸入,這是潛在的安全性威脅。 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。
<%@ 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>
備註
屬性 TitleTextStyle 會取得您用來變更 屬性中所 TitleText 包含標題外觀的物件參考 TableItemStyle 。
屬性 TitleTextStyle 會定義 控制項中 Login 標題的外觀。 此屬性是唯讀的;不過,您可以設定其傳回之 TableItemStyle 物件的屬性。 您可以在 表單 Property-Subproperty
中宣告設定這些屬性,其中 Subproperty
代表類別的屬性 TableItemStyle (,例如, TitleStyle-ForeColor
) 。 例如, TitleStyle.ForeColor
您可以在表單 Property.Subproperty
中以程式設計方式設定 屬性 () 。
常見的設定包括自訂背景色彩、文字色彩和字型屬性。 屬性 TitleTextStyle 會定義 屬性的外觀 TitleText 。
屬性的 TitleTextStyle 樣式設定會與控制項的 Login 樣式設定合併。 屬性中 TitleTextStyle 所做的任何設定會覆寫 控制項屬性 Login 中的對應設定。
設定會覆寫 TitleTextStyle 下列 Login 樣式屬性:
當您使用範本來定義控制項的外觀 Login 時, TitleTextStyle 屬性不會有任何作用。