I'm having an issue where I want to be able to reference the class of a UserControl in a page, like this
FooControl foo = (FooControl) LoadControl("~/controls/FooControl.ascx");
foo.Bar= "Bazbazbaz";
this.Controls.Add(foo);Where FooControl is a UserControl in the folder "controls". So far I have figured the following out:
1) You must use the @Reference directive at the top of the markup page for each control you want to reference this way (adding an entry in web.config/system.web/pages/controls won't work)
2) You don't need to have the @Register directive or an instance of the control on the page.
3) The control needs to have a "ClassName" attribute defined in it's @Control tag. For inline controls, this is already done. For code-behind, you have to add that to the tag in the ascx file (I' ...
Go to the complete details ...