Wednesday, February 20, 2008


  • Identifies a container control that creates a new ID namespace within a Page object's control hierarchy. This is a marker interface only.
  • Any control that implements this interface creates a new namespace in which all child control ID attributes are guaranteed to be unique within an entire application. The marker provided by this interface allows unique naming of the dynamically generated server control instances within the Web server controls that support data binding. These controls include the Repeater, DataGrid, DataList, CheckBoxList, ChangePassword, LoginView, Menu, SiteMapNodeItem, and RadioButtonList controls.
  • When you develop templated controls, you should implement this interface to avoid naming conflicts on a page.
  • FindControl searches the current naming container for the specified server control.
  • A naming container is any control that implements the INamingContainer interface. Both the MasterPage and Content controls are naming containers. FindControl only searches inside the current naming container.
  • A naming container also mangles its children’s ClientID property. Mangling ensures all ClientID properties are unique on a page. For instance, the ID for a Label control is “Label1”, but the ClientID of the Label is “ctl00_ContentPlaceHolder1_Label1”. Each level of naming container prepends it’s ID to the control (the MasterPage control ID in this form is ctl00).
  • So when a Control is a naming container, the UniqueID for all controls within it will have the parent's ID as a prefix. So while a child control might have ID "foo", its UniqueID will be "parentID$foo" (where parentID = the ID of the parent).

INamingContainer Interface

TRULY Understanding Dynamic Controls (Part 4)

ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps

blog comments powered by Disqus