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 參考包含定義標題文字外觀的屬性。
- 屬性
範例
以下程式碼範例透過設定該物件的屬性TableItemStyleTitleTextStyle,來設定標題的文字顏色、背景色與字體粗細。
這很重要
此範例包含一個接受使用者輸入的文字框,這可能構成安全威脅。 預設情況下,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>
備註
該 TitleTextStyle 屬性會獲得一個物件的參考 TableItemStyle ,你用它來改變該物件中標題 TitleText 的外觀。
TitleTextStyle該財產定義了該產權在控制中Login呈現的外觀。 此屬性為唯讀;不過,你可以設定它回傳的物件屬性 TableItemStyle 。 你可以以宣告式 Property-Subproperty的形式設定這些屬性,其中 Subproperty 表示類別 TableItemStyle 的屬性(例如, TitleStyle-ForeColor)。 你可以在 Form Property.Subproperty 中以程式方式設定該屬性(例如 TitleStyle.ForeColor)。
常見設定包括自訂背景色、文字顏色及字型屬性。 TitleTextStyle財產定義了房產TitleText的外觀。
屬性的樣式設定 TitleTextStyle 會與控制項的樣式設定 Login 合併。 屬性中 TitleTextStyle 的任何設定都會覆蓋控制項屬性 Login 中相應的設定。
以下 Login 樣式屬性會被 TitleTextStyle 設定覆蓋:
當你用模板來定義控制項的外觀 Login 時,屬性 TitleTextStyle 本身就沒有影響。