Hi all!
I created a new class, which has the UserControl as a base class.
Now I want to create an instance of my new class, by creating a new
usercontrol and casting it to my new class using the next line of code:
MyClass instance = (MyClass)((UserControl) Page.LoadControl("an_ascx.ascx"));
This is how I defined MyClass and its constructor:
public class MyClass : UserControl
{
public PortalGlobalModuleControl() : base()
{
this.RefreshPortalSettings();
} // Constructor
}
When I execute this line of code, I get an Invallid Cast exception. (Casting
from control to usercontrol is no problem).
What am I missing here? I thought this could not give any problems...
Thanks in advance,
Michel