Reputation: 453
How can I get the instance of the content page from the maste page?
I need it for that:
All my content pages derive from BasePage class (and BasePage derives from System.Web.UI.Page), the BasePage has a property Index.
The derived page set it's value so that master page can read id and apply special CSS to corresponded menu item that is located on the master page.
Upvotes: 1
Views: 638
Reputation: 460138
You could define a public function to change the css in the MasterPage that you can call from derived pages on index change.
DirectCast(Me.Page.Master, YourMasterPageType).ChangeCss()
Upvotes: 0
Reputation: 68476
Just cast the current page from your MasterPage
as your BasePage
:
BasePage currentPage = (BasePage)this.Page;
int index = currentPage.Index;
SetMenuIndex(index);
Upvotes: 5