Getting instance of content page within the master page
How can I get the instance of the co开发者_JS百科ntent 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.Just cast the current page from your MasterPage
as your BasePage
:
BasePage currentPage = (BasePage)this.Page;
int index = currentPage.Index;
SetMenuIndex(index);
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()
精彩评论