Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do I really need InamingContainer Interface?

Tags:

asp.net

I read in MSDN InamingContainer is a marker interface for creating unique name. When is it really necessary ?

like image 616
user310291 Avatar asked Mar 28 '10 08:03

user310291


2 Answers

Frankly, it's required when your control has a child with an id. Whereas you can use multiple instances of your control on a single page, you have to mark your control with INamingContainer interface. This is the most senario for CompositeControls, thus it has derived INamingContainer by default.

like image 169
Mehdi Golchin Avatar answered Oct 25 '22 00:10

Mehdi Golchin


From INamingContainer Interface

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.

like image 27
Adriaan Stander Avatar answered Oct 24 '22 23:10

Adriaan Stander