C# – Sending Event from a Page to its Master Page in ASP.NET

asp.netceventsmaster-pages

How do I raise an event in a content page that its master page can then respond to?

For example, I have a content page which is using a master page. The master page contains the website navigation bar. Depending on the page I'm on, I'd like to send an event to the master page to change the CSS class of the current page menu item in the navigation bar.

I'm using Visual Studio 2008 and ASP.NET 3.5 and C#.

Thanks!

Best Answer

Edit, from what your asking you don't really need an event, you just want to call a method on the master. off the top of my head, in the master:

public void ChangeCss(string className)
{
    someObject.CssClass = className;
}

then in your page:

(this.Master as MyMasterType).ChangeCss("myclass");