I have a BasePage which inherits from System.Web.UI.Page, and every page that inherits the BasePage will have the same master page.
How do I cast the Page.Master of the BasePage to the specific master page so I can access properties on it?
A better way is to add the MasterType property to the pages that use that master. Then you can simply access the master page properties through the page object.
<%@ MasterType VirtualPath="~/site.master" %>
You just use this in your code:
this.Master.propertyName
To access the property of the master page for the current page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With