Hi all,
I have created a new class (MyCustomUserControl) which is based on
UserControl.
I create an instance of my class using the next line of code:
MyCustomUserControl mycontrol = (MyCustomUserControl) ((UserControl)
Page.LoadControl("pathtoanascx.ascx"));
This line of code, gives me an InvallidCastException. (The cast from
TemplateControl to UserControl is no problem)
My class and its constructor is defined as followed:
public class MyCustomUserControl : UserControl
{
public MyCustomUserControl () : base()
{
} // Constructor
}
I thought this might not be a problem. What am I missing?
Thanks in advance,
Michel