Reputation: 3675
How do you catch a custom event raised by a master page?
On my master page I have a custom event and delegate:
public event SignOutHandler SignOut;
public delegate void SignOutHandler();
This is raised when a link button on the master page is clicked.
if (SignOut != null)
{
SignOut();
}
In a user control on the page I'd like to subscribe to that event, but I don't know how I'm supposed to access it. Normally I'd do something like:
MyInstantiatedMasterPage.SignOut += new MyMasterPage.SignOutHandler(MyEvent);
but dealing with a master page means that this isn't possible.
Upvotes: 2
Views: 4419
Reputation: 15568
It's instantiated as a global object, which is what you'll need to use:
((MyMasterPage)Master).SignOut += new MyMasterPage.SignOutHandler(MyEvent);
Upvotes: 4