INamingContainer Interface
Assembly: System.Web (in system.web.dll)
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. For more information, see ASP.NET Control Designers Overview.
The following code example demonstrates a templated custom server control that implements the INamingContainer interface. When this custom server control is used in an .aspx file, it will provide a unique namespace for any server controls that it contains.
using System; using System.Collections; using System.Web; using System.Web.UI; namespace TemplateControlSamples { public class RepeaterItem : Control, INamingContainer { private int itemIndex; private object dataItem; public RepeaterItem(int itemIndex, object dataItem) { this.itemIndex = itemIndex; this.dataItem = dataItem; } public object DataItem { get { return dataItem; } } public int ItemIndex { get { return itemIndex; } } } }
package TemplateControlSamples;
import System.*;
import System.Collections.*;
import System.Web.*;
import System.Web.UI.*;
public class RepeaterItem extends Control implements INamingContainer
{
private int itemIndex;
private Object dataItem;
public RepeaterItem(int itemIndex, Object dataItem)
{
this.itemIndex = itemIndex;
this.dataItem = dataItem;
} //RepeaterItem
/** @property
*/
public Object get_DataItem()
{
return dataItem;
} //get_DataItem
/** @property
*/
public int get_ItemIndex()
{
return itemIndex;
} //get_ItemIndex
} //RepeaterItem
import System; import System.Collections; import System.Web; import System.Web.UI; package TemplateControlSamples { public class RepeaterItem extends Control implements INamingContainer { private var itemIndex : int; private var dataItem; function RepeaterItem(itemIndex : int, dataItem) { this.itemIndex = itemIndex; this.dataItem = dataItem; } function get DataItem() { return dataItem; } function get ItemIndex() : int { return itemIndex; } } }
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
INamingContainer MembersSystem.Web.UI Namespace
Control Class
Page