ASP.NET: How To Easily Reference MasterPage Members
I’ll lay it out very simply:
- On your .aspx page, include the following:
<%@ MasterType virtualpath="~/myMasterPage.master" %>
- To reference the members, simply type
That’s it! It’s better than casting a new master page object for every function, that’s for sure.
NOTE: Content pages load BEFORE master pages, so if you’re going to reference something on your master page, be sure you don’t need it during your content page’s Page_Load event!