If we use Load control, perhaps (as in the GotDotNetMenuSource example available all over the place)
cwd.cwdmenu.UI.Components.Navigation.MenuCollapsing adsMenu = new cwd.cwdmenu.UI.Components.Navigation.MenuCollapsing();
adsMenu = (cwd.cwdmenu.UI.Components.Navigation.MenuCollapsing)LoadControl("UI/Components/Navigation/Menu/Menu.ascx");
we can then programatically add this to say, a panel, in the 'display page'
panel1.Controls.Add(adsMenu)
[[
OR - if we were to add it to the 'display page' using the designer/html
<%@ Register TagPrefix="cwd" TagName="ads" src="UI/Components/Navigation/Menu/Menu.ascx" %>
..... and then add the tag.
OR .... if we have overridden Render - we no longer have an ascx file as the src - so we use
<%@ Register TagPrefix="ads" Namespace="cwd.cwdmenu.UI.Components.Navigation" Assembly = "cwdmenu" %>
.... and then add the tag
]]
(see ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconcompositecontrolsample.htm)
This much I am fine with.
But look above again, in the first instance when we want to add the menu to 'display page' programatically we use LoadControl ..... but what if we have Overidden Render in a custom control which has been built programmatically and doesn't have an ascx file .... how can we use Load Control without an ascx file ????? LoadControl only has one constructor.
The answer maybe to simply leave out the line
adsMenu = (cwd.cwdmenu.UI.Components.Navigation.MenuCollapsing)LoadControl("UI/Components/Navigation/Menu/Menu.ascx");
I could presume the actual function of LoadControl as being specific to load the ascx file, the html - seeing as the control has already been instantiated in the line above it - after all we don't have LoadControl with a Label or Panel :: but then again you would have thought that the base classes Render method would do this automatically.
So what exactly in the function of LoadControl - what exactly does it do ?
Note :: I haven't actually tried this yet as I haven't rebuilt my control and ridded myself of the ascx file as yet - I am asking to check with anyone if they have done something similar.
Has anyone come across this yet ??? Maybe I am missing something ?