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

Public ReadOnly Property Attributes As AttributeCollection
public AttributeCollection Attributes { get; }
Web ページ内にあるサーバー コントロール タグで表現されるすべての属性名と値のペアが格納されている System.Web.UI.AttributeCollection オブジェクト。

このプロパティを使用して、HTML サーバー コントロールの属性にプログラムによってアクセスします。すべての HTML サーバー コントロールは、その属性を Control.ViewState プロパティに格納します。
.NET Framework では、HTML 属性は、その属性が属している HTML サーバー コントロールのプロパティのように扱われます。
属性のコレクションの詳細については、System.Web.UI.AttributeCollection クラスのトピックを参照してください。

Attributes プロパティを使用して、HtmlSelect コントロールの属性を確認する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <script language="VB" runat="server"> Sub Page_Load(sender As Object, e As EventArgs) Message.InnerHtml = "<h4>" & "The select box's attributes collection contains:" & "</h4>" Dim keys As IEnumerator = Select1.Attributes.Keys.GetEnumerator() While keys.MoveNext() Dim key As String = CType(keys.Current, String) Message.InnerHtml &= key & "=" & Select1.Attributes(key) & "<br>" End While End Sub 'Page_Load </script> <body> <h3>HtmlControl Attribute Collection Example</h3> Make a selection: <select id="Select1" style="font: 12pt verdana; background-color:yellow; color:red;" runat="server"> <option>Item 1</option> <option>Item 2</option> <option>Item 3</option> </select> <p> <span id="Message" MaintainState="false" runat="server" /> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <script language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) { Message.InnerHtml = "<h4>The select box's attributes collection contains:</h4>"; IEnumerator keys = Select.Attributes.Keys.GetEnumerator(); while (keys.MoveNext()) { String key = (String)keys.Current; Message.InnerHtml += key + "=" + Select.Attributes[key] + "<br>"; } } </script> <body> <h3>HtmlControl Attribute Collection Example</h3> Make a selection: <select id="Select" style="font: 12pt verdana; background-color:yellow; color:red;" runat="server"> <option>Item 1</option> <option>Item 2</option> <option>Item 3</option> </select> <p> <span id="Message" MaintainState="false" runat="server" /> </body> </html>
<%@ Page Language="JScript" AutoEventWireup="True" %> <html> <script language="jscript" runat="server"> function Page_Load(sender: Object, e: EventArgs){ Message.InnerHtml = "<h4>The select box's attributes collection contains:</h4>" var keys: IEnumerator = Select1.Attributes.Keys.GetEnumerator() while(keys.MoveNext()){ var key: String = String(keys.Current) Message.InnerHtml += key + "=" + Select1.Attributes(key) + "<br>" } } </script> <body> <h3>HtmlControl Attribute Collection Example</h3> Make a selection: <select id="Select1" style="font: 12pt verdana; background-color:yellow; color:red;" runat="server"> <option>Item 1</option> <option>Item 2</option> <option>Item 3</option> </select> <p> <span id="Message" MaintainState="false" runat="server" /> </body> </html>

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に収録されているすべての辞書からHtmlControl.Attributes プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlControl.Attributes プロパティのページへのリンク