Subscribing to custom events from dynamically created UserControls

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top