I'm looking to create an instance of a user control programatically in a codebehind of a web site*. The only ways I've found to reference the class of the user control programatically have been:
- Register the control in the web.config and drop the control on the page (works, but I don't want the control on the page as I want to dynamically add it).
- Add a <%@ Reference Control="Name.aspx"> to the aspx page at the top.
Ideally I would want to have any aspx page reference the control without having to put the <%@ Reference> declaration at the top of each page. I know I can "Register" controls in the web.config so I don't have to do that on every page, so I'm wondering if something similar exists for references. I'm almost certain I'm missing something about the whole registering/referencing concept, so perhaps just an explanation of what the best way to do this is in order.
*Web-site type project and not web application if this matters.