Monday, January 25, 2010

INamingContainer Unique Name

The Web page is a naming container for the controls that are added to it. A naming container defines a unique namespace for control names. Within a naming container, every control must be uniquely identifiable.

How can multiple GridView controls be added to a Web page, and then, when their child controls are created, each has its own unique ID property? This is because the GridView control is a naming container.

The naming container for a given child control is a control above it (parent or higher) in the hierarchy that implements the INamingContainer interface. A server control implements this interface to create a unique namespace for populating the UniqueID property values of its child server controls. The UniqueID property contains the fully qualified name of the control. The difference between this property and the ID property is that the UniqueID property is generated automatically by the NamingContainer and contains the NamingContainer information.

No comments: