views:

24

answers:

1

Hi,

I've seen code to handle MasterPage events in the content Page, but if I'm loading a UserControl dynamically into the Page, can I handle the event in the UserControl instead?

Basically I have a button on the MasterPage, when it's clicked I need to make the UserControl do something, such as display text or change a value in a form.

Failing that, is it possible to make an event from one dynamically loaded UserControl fire in another on the same page? I could then replace the button in the MasterPage with one in another UserControl

Thanks all.

A: 

This is very similar to this stackoverflow question.

The answer to that question should also apply to yours: your Page knows its master and knows its child controls. It can wire-up a handler on the child control to an event on the master page, so the child control can perform necessary functionality when the even occurs on the master page.

mikemanne
Thanks - I did look before posting but must have missed that one. Cheers!
Dave