AttributeCollection.CssStyle プロパティ
アセンブリ: System.Web (system.web.dll 内)

現在のサーバー コントロールのスタイルを格納している CssStyleCollection オブジェクト。

特定の HTML サーバー コントロールについて宣言されたスタイルは、そのコントロールを格納している Web フォーム ページが解析されるときに CssStyleCollection オブジェクトに追加されます。このプロパティを使用して、サーバー コントロールについて宣言されたスタイルを追加、削除、および反復処理します。

プログラムによってサーバー コントロールの AttributeCollection に CSS スタイル値を追加する方法の例を次に示します。ボタンをクリックすると、TextBox サーバー コントロールの背景色 TextBox1 は、DropDownList サーバー コントロールで選択された項目 DropDownList1 に設定されます。
Private Sub Button2_Click(sender As Object, e As System.EventArgs) Dim myColor As String Dim myAttributes As AttributeCollection = TextBox1.Attributes myColor = DropDownList1.Items(DropDownList1.SelectedIndex).Text ' Add the attribute "background-color" in to the CssStyle. myAttributes.CssStyle.Add("background-color", myColor) End Sub
private void Button2_Click(object sender, System.EventArgs e) { string myColor; AttributeCollection myAttributes = TextBox1.Attributes; myColor = DropDownList1.Items[DropDownList1.SelectedIndex].Text; // Add the attribute "background-color" in to the CssStyle. myAttributes.CssStyle.Add("background-color",myColor); }
private void Button2_Click(Object sender, System.EventArgs e) { String myColor; System.Web.UI.AttributeCollection myAttributes = TextBox1.get_Attributes(); myColor = DropDownList1.get_Items().get_Item(DropDownList1. get_SelectedIndex()).get_Text(); // Add the attribute "background-color" in to the CssStyle. myAttributes.get_CssStyle().Add("background-color",myColor); } //Button2_Click

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からAttributeCollection.CssStyle プロパティを検索する場合は、下記のリンクをクリックしてください。

- AttributeCollection.CssStyle プロパティのページへのリンク