次の方法で共有


Login.TitleTextStyle プロパティ

定義

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 オブジェクトのプロパティを設定して、タイトルのテキストの色、背景色、フォントの太さを設定します。

Important

この例には、潜在的なセキュリティ上の脅威であるユーザー入力を受け入れるテキスト ボックスが含まれています。 既定では、ASP.NET Web ページでは、ユーザー入力にスクリプトや 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 プロパティは、TitleText プロパティに含まれるタイトルの外観を変更するために使用するTableItemStyle オブジェクトへの参照を取得します。

TitleTextStyle プロパティは、Login コントロール内のタイトルの外観を定義します。 このプロパティは読み取り専用です。ただし、返される TableItemStyle オブジェクトのプロパティを設定できます。 これらのプロパティは、 Property-Subproperty形式で宣言によって設定できます。 Subproperty は、 TableItemStyle クラスのプロパティ (たとえば、 TitleStyle-ForeColor) を表します。 フォーム Property.Subproperty ( TitleStyle.ForeColor など) でプログラムでプロパティを設定できます。

一般的な設定には、ユーザー設定の背景色、テキストの色、およびフォント プロパティが含まれます。 TitleTextStyle プロパティは、TitleText プロパティの外観を定義します。

TitleTextStyle プロパティのスタイル設定は、Login コントロールのスタイル設定とマージされます。 TitleTextStyle プロパティで行われた設定は、Login コントロールのプロパティの対応する設定をオーバーライドします。

次の Login スタイル プロパティは、 TitleTextStyle 設定によってオーバーライドされます。

テンプレートを使用して Login コントロールの外観を定義する場合、 TitleTextStyle プロパティは無効になります。

適用対象

こちらもご覧ください