Dynamic UserControls and delegates

How does one gain access to delegate within a dynamically loaded usercontrol.  Here is short snippet of code:

        Dim ctlControl As UserControl
        ctlControl = LoadControl("~/FolderName/TomsTree.ascx")
        PlaceHolder1.Controls.Add(ctlControl)

        ctlControl = LoadControl("~/FolderName/MyDataGrid.ascx")
        PlaceHolder1.Controls.Add(ctlControl)

TomsTree has a delegate that needs to communicate with MyDataGrid when an event occurs.  This works perfectly if I declare the controls at design time...but how would I add an event handler and addressof to dynamically loaded controls such as this?
       
LVL 2
awiincAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EugeneTrukhinCommented:
just a comment: may be through reflection?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awiincAuthor Commented:
Thank you Eugene, but I did figure it out by finding a control and then referencing the event: see below.

Dim obj1 As ucWithDelegate = CType(PlaceHolder1.FindControl("NameOfControlToFind1"),ucWithDelegate)
Dim obj2 As uclisteningforDelegate = CType(PlaceHolder1.FindControl("NameOfControlToFind2"), uclisteningforDelegate)
AddHandler obj1.CategoryChanged, AddressOf obj2.CategoryChanged
0
EugeneTrukhinCommented:
nice, it is good to know!
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

awiincAuthor Commented:
How do I award EugeneTrukhin 100 points for responding.  I would like to delete this question from ASP.NET since I have figured the problem out without receiving an answer.  If this is not possible then just award Eugene all 250 points.
0
EugeneTrukhinCommented:
i think moderator can delete this topic.
0
EugeneTrukhinCommented:
or u can award yourself :)
0
awiincAuthor Commented:
Can he delete and award you 100 points for responding?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.