When do I really need an InamingContainer interface?

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

+5
source share
3 answers

Honestly, this is necessary when your control has a child with an identifier. If you can use multiple instances of your control on the same page, you should tag your control with the INamingContainer interface. This is the most cenarii for CompositeControls , so it got INamingContainer by default.

+5
source

From the INamingContainer Interface

Any control that implements this interface creates a new namespace in which all the ID attributes of the child control are guaranteed to be unique throughout the application. The token provided by this interface allows unique naming of dynamically generated server control instances within the web server that controls data binding support. These controls include Repeater, DataGrid, DataList, CheckBoxList, ChangePassword, LoginView, Menu, SiteMapNodeItem and RadioButtonList controls.

When you design template controls, you must implement this interface to avoid name conflicts on the page.

+2
source

Source: https://habr.com/ru/post/1305346/


All Articles