This documentation is archived and is not being maintained.

UserControl.Attributes Property

Gets a collection of all attribute name and value pairs declared in the user control tag within the .aspx file.

[Visual Basic]
Public ReadOnly Property Attributes As AttributeCollection
[C#]
public AttributeCollection Attributes {get;}
[C++]
public: __property AttributeCollection* get_Attributes();
[JScript]
public function get Attributes() : AttributeCollection;

Property Value

An AttributeCollection object that contains all the name and value pairs declared in the user control tag.

Example

[Visual Basic, C#] The following example uses the user control's Attributes property to access the Message attribute declared in the custom control tag that instantiated the user control on the page that contains it.

[Visual Basic] 


    Sub Page_Load(sender As object ,e As EventArgs)
        Response.Write("<h2><b> User Control Properties Example</b></h2><br>")
        ' 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"))                    

[C#] 


void Page_Load(object sender, System.EventArgs e)
{
        Response.Write("<h2><b> User Control Properties Example</b></h2><br>");
        // 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"]);
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

UserControl Class | UserControl Members | System.Web.UI Namespace | AttributeCollection

Show: