Subscribing to custom events from dynamically created UserControls

  • Thread starter Thread starter TJ
  • Start date Start date
T

TJ

What is the best approach to subscribe to events from a UserControl
that has been dynamically created at runtime, and where we don't know
the UserControl type. I don't know the UserControl type because the
program loads a different usercontrol based on a users selection.

Lets say I am raising an Event called SomethingUpdated from my
UserControl.
When I know the UserControl type then in my parent aspx I can simply
do this:
protected MyUserControl MyUserControl1;
MyUserControl1.SomethingUpdated += new
EventHandler(Form1_SomethingUpdated);

But when I don't know the type of the UserControl I don't know how to
access the public SomethingUpdated Event.

What is the best approach to this?

thanks,
tj
 
Back
Top