Login.FailureTextStyle 屬性

定義

會獲得一組屬性的參考,這些屬性定義了控制項中 Login 錯誤文字的外觀。

public:
 property System::Web::UI::WebControls::TableItemStyle ^ FailureTextStyle { System::Web::UI::WebControls::TableItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.TableItemStyle FailureTextStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.FailureTextStyle : System.Web.UI.WebControls.TableItemStyle
Public ReadOnly Property FailureTextStyle As TableItemStyle

屬性值

TableItemStyle 參考包含定義錯誤文字外觀的屬性。

屬性

範例

以下程式碼範例透過設定該物件的背景與文字顏色屬性TableItemStyleFailureTextStyle,來指定登入失敗的文字樣式。

<%@ Page Language="C#" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" FailureText="There was an error while logging you in. Please try again.">
                <FailureTextStyle ForeColor="White" BackColor="Red"></FailureTextStyle>
            </asp:Login>

        </form>
    </body>
</html>
<%@ Page Language="VB" AutoEventWireup="False"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" FailureText="There was an error while logging you in. Please try again.">
                <FailureTextStyle ForeColor="White" BackColor="Red"></FailureTextStyle>
            </asp:Login>

        </form>
    </body>
</html>

備註

這個 FailureTextStyle 屬性會引用一個 TableItemStyle 物件,用來改變登入失敗文字的外觀。 預設是以紅色顯示文字。

此屬性為唯讀;不過,你可以設定它回傳的物件屬性 TableItemStyle 。 你可以以宣告式 Property-Subproperty的形式設定這些屬性,其中 Subproperty 表示類別 TableItemStyle 的屬性(例如, FailureTextStyle-ForeColor)。 你可以在 Form Property.Subproperty 中以程式方式設定該屬性(例如 FailureTextStyle.ForeColor)。

常見設定包括自訂背景色、文字顏色及字型屬性。 FailureTextStyle財產定義了房產FailureText的外觀。

屬性的樣式設定 FailureTextStyle 會與控制項的樣式設定 Login 合併。 屬性中 FailureTextStyle 的任何設定都會覆蓋控制項屬性 Login 中相應的設定。

以下 Login 控制樣式屬性會被 FailureTextStyle 設定覆蓋:

當你用模板來定義控制項的外觀 Login 時,屬性 FailureTextStyle 本身就沒有影響。

適用於

另請參閱