UserControl.Attributes Property

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

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public AttributeCollection Attributes { get; }
/** @property */
public AttributeCollection get_Attributes ()

public function get Attributes () : AttributeCollection

Not applicable.

Property Value

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

The following code 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.

// 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 Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: