次の方法で共有


UserControl.Attributes プロパティ

.aspx ファイル内のユーザー コントロール タグで宣言されたすべての属性名と値ペアのコレクションを取得します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public ReadOnly Property Attributes As AttributeCollection
'使用
Dim instance As UserControl
Dim value As AttributeCollection

value = instance.Attributes
public AttributeCollection Attributes { get; }
public:
property AttributeCollection^ Attributes {
    AttributeCollection^ get ();
}
/** @property */
public AttributeCollection get_Attributes ()
public function get Attributes () : AttributeCollection
適用できません。

プロパティ値

ユーザー コントロール タグで宣言されたすべての名前と値ペアを格納する AttributeCollection オブジェクト。

使用例

ユーザー コントロールの Attributes プロパティを使用して、カスタム コントロール タグで宣言された Message 属性にアクセスするコード例を次に示します。ページ上のユーザー コントロールは、このカスタム コントロール タグによってインスタンス化されています。

' Retrieve and display the 'Message' attribute tag 
' initialized in the .aspx code.
Response.Write("<b>Message tag value declared in the aspx file is : </b>" + myControl.Attributes("Message"))                    
// Retrieve and display the 'Message' attribute tag 
// initialized in the .aspx code.
Response.Write("<b>Message tag value declared in the aspx file is : </b>" + myControl.Attributes["Message"]);
void Page_Load(Object sender, System.EventArgs e)
{
     get_Response().Write(
        "<h2><b> User Control Properties Example</b></h2><br />");
     // Retrieve and display the 'Message' attribute tag 
    // initialized in the .aspx code.
     get_Response().Write(
        "<b>Message tag value declared in the aspx file is : </b>"
        + myControl.get_Attributes().get_Item("Message"));

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

UserControl クラス
UserControl メンバ
System.Web.UI 名前空間
AttributeCollection