We currently have all of our tracking / analytic code in a usercontrol (ascx). We like this because, using our CMS, we can just drop the control on any page that needs tracking.
The issue is now it is possible for a user to inadvertently drop a control on a page that may already have it included. For example : We include the control on a master page – then again on a page that inherits from this master.
What would be the best way to insure the user control is used only once when rendering the page?
There is no way than to loop all controls and their parents/childs.
For example:
and you can check it so:
Note: all untested