System.Web.UI.Control.NamingContainer Property

Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same Control.ID property value.

Syntax

[System.ComponentModel.Browsable(false)]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public virtual Control NamingContainer { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Each page in an ASP.NET Web application contains a hierarchy of controls. This hierarchy is not dependent on whether a control generates UI visible to the user. The naming container for a given control is the parent control above it in the hierarchy that implements the System.Web.UI.INamingContainer interface. A server control that implements this interface creates a unique namespace for the Control.ID property values of its child server controls. You can use the Control.NamingContainer property of a naming container's child control to get a reference to its parent container.

Creating a unique namespace for server controls is particularly important when you bind Web server controls to data, such as the System.Web.UI.WebControls.Repeater and System.Web.UI.WebControls.DataList server controls. When multiple entries in the data source create multiple instances of a server control that is a child of the repeating control, the naming container ensures that each instance of these child controls have Control.UniqueID property values that do not conflict. The default naming container for a page is the instance of the System.Web.UI.Page class that is generated when that page is requested.

The Control.ClientID property contains the value that is rendered as the element's id attribute in the HTML markup. Depending on the value that you assign to the Control.ClientIDMode property, the value that is generated for the Control.ClientID property might include the ID of the Control.NamingContainer object. When you set Control.ClientIDMode to ClientIDMode.Static, the Control.ClientID value does not include the ID of the Control.NamingContainer object. When you set Control.ClientIDMode to either ClientIDMode.AutoID or ClientIDMode.Predictable, the Control.ClientID value will include the ID from the Control.NamingContainer object. For more information, see ASP.NET Control Identification.

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0