Share via


PasswordRecovery.TextBoxStyle 屬性

定義

取得定義 PasswordRecovery 控制項中文字方塊外觀之樣式屬性集合的參考。

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

屬性值

Style

Style 的參考,包含了定義 PasswordRecovery 控制項中文字方塊外觀的屬性。

屬性

範例

如果使用者輸入使用者名稱時發生錯誤,下列程式碼範例會變更 [使用者名稱] 文字方塊的外觀。

重要

此範例包含一個文字方塊,可接受使用者輸入,這是潛在的安全性威脅。 根據預設,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 PasswordRecovery1_UserLookupError(object sender, EventArgs e)
    {
        PasswordRecovery1.TextBoxStyle.BackColor = System.Drawing.Color.Red;
        PasswordRecovery1.TextBoxStyle.ForeColor = System.Drawing.Color.White;
    }
</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:passwordrecovery id="PasswordRecovery1" runat="server" 
        onuserlookuperror="PasswordRecovery1_UserLookupError">
        <textboxstyle backcolor="#C0FFC0"></textboxstyle>
    </asp:passwordrecovery>

</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 PasswordRecovery1_UserLookupError(ByVal sender As Object, ByVal e As System.EventArgs)
        PasswordRecovery1.TextBoxStyle.BackColor = System.Drawing.Color.Red
        PasswordRecovery1.TextBoxStyle.ForeColor = System.Drawing.Color.White
    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">
    <asp:passwordrecovery id="PasswordRecovery1" runat="server" 
        onuserlookuperror="PasswordRecovery1_UserLookupError">
        <textboxstyle backcolor="#C0FFC0"></textboxstyle>
    </asp:passwordrecovery>

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

備註

屬性 TextBoxStyle 會定義 控制項中 PasswordRecovery 文字方塊的外觀。 此屬性是唯讀的;不過,您可以設定其傳回之 Style 物件的屬性。 您可以在 表單 Property-Subproperty 中宣告設定這些屬性,其中 Subproperty 代表類別的屬性 Style (,例如, TextBoxStyle-ForeColor) 。 您也可以在表單 Property.Subproperty 中以程式設計方式設定屬性 (,例如, TextBoxStyle.ForeColor) 。

常見的設定包括自訂背景色彩、文字色彩和字型屬性。

屬性的 TextBoxStyle 樣式設定會與控制項的 PasswordRecovery 樣式設定合併。 屬性中 TextBoxStyle 所做的任何設定會覆寫 控制項屬性 PasswordRecovery 中的對應設定。

設定會覆寫 TextBoxStyle 下列 PasswordRecovery 屬性:

當您使用範本來定義控制項的外觀 PasswordRecovery 時, TextBoxStyle 屬性不會有任何作用。

適用於

另請參閱