Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Subscribing to custom events from dynamically created UserControls

0 views
Skip to first unread message

TJ

unread,
May 1, 2008, 10:17:32 PM5/1/08
to
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

TJ

unread,
May 2, 2008, 12:11:59 AM5/2/08
to
I have solved my problem. I used this solution:
http://www.codeproject.com/KB/aspnet/EventsAcrossUCs.aspx

Thanks Thomas Eyde

0 new messages