By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,617 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,617 IT Pros & Developers. It's quick & easy.

What does the INamingContainer Inteface do?

P: n/a
Interface definitions do no not contain implementation, only
signtures. That is there real purpose. Here thow we have an Inteface
which does not have any implementation code but it has to be included
in the creation of a Web User Control. Please tell me how it actually
does something?

Regards

John L
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
It's a marker interface..I'm not 100% sure how it works, but if you check
out how the constructor control work, you'll see:

if (this is INamingContainer){
this.flags[0x80] = true;
}
as you can see, it checks if the control implements INamingContainer, and if
it does, it sets a flag to a value...that's typically how marker interfaces
work...something checks if the object implements the interface, and if it
does, some magic is handled....how that's used from then on end, I'm not
sure....but what it actually does it ensure that controls are given unique
ids...this is important if you are creating composite controls or something
where you are specifying an ID for the dynamically created
child-controls...if you don't implement INamingContainer and you drop the
control twice on the same page (say for paging at the top and bottom of a
repeater), you'll have conflicting control IDs...INamingContainer ensures
that controls have a unique name. Additionally, without this uniqueness,
you'll likely run into problems with postback events not firing properly
because control Ids won't be appropriate...

HTH
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"gemel" <jo***@glenavon1.demon.co.uk> wrote in message
news:nh********************************@4ax.com...
Interface definitions do no not contain implementation, only
signtures. That is there real purpose. Here thow we have an Inteface
which does not have any implementation code but it has to be included
in the creation of a Web User Control. Please tell me how it actually
does something?

Regards

John L

Nov 19 '05 #2

P: n/a
Vko
Perferct answer :)
"Karl Seguin" wrote:
It's a marker interface..I'm not 100% sure how it works, but if you check
out how the constructor control work, you'll see:

if (this is INamingContainer){
this.flags[0x80] = true;
}
as you can see, it checks if the control implements INamingContainer, and if
it does, it sets a flag to a value...that's typically how marker interfaces
work...something checks if the object implements the interface, and if it
does, some magic is handled....how that's used from then on end, I'm not
sure....but what it actually does it ensure that controls are given unique
ids...this is important if you are creating composite controls or something
where you are specifying an ID for the dynamically created
child-controls...if you don't implement INamingContainer and you drop the
control twice on the same page (say for paging at the top and bottom of a
repeater), you'll have conflicting control IDs...INamingContainer ensures
that controls have a unique name. Additionally, without this uniqueness,
you'll likely run into problems with postback events not firing properly
because control Ids won't be appropriate...

HTH
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"gemel" <jo***@glenavon1.demon.co.uk> wrote in message
news:nh********************************@4ax.com...
Interface definitions do no not contain implementation, only
signtures. That is there real purpose. Here thow we have an Inteface
which does not have any implementation code but it has to be included
in the creation of a Web User Control. Please tell me how it actually
does something?

Regards

John L


Nov 19 '05 #3

P: n/a
Hi...

From the MSDN documentation:

"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, ListBox, CheckBoxList, HtmlSelect, and RadioButtonList
controls."

Basically, this interface causes the ASP.NET runtime to do it's job relative
to control naming. It is a "marker" interface, meaning that some piece of
code, e.g., the ASP.NET runtime, will use its presence to take some action.

Hope this helps.

John Puopolo
..NET Fan

"gemel" <jo***@glenavon1.demon.co.uk> wrote in message
news:nh********************************@4ax.com...
Interface definitions do no not contain implementation, only
signtures. That is there real purpose. Here thow we have an Inteface
which does not have any implementation code but it has to be included
in the creation of a Web User Control. Please tell me how it actually
does something?

Regards

John L

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.