Calling a function from the MasterPage in a Page is quite straigt forward but how do I call it for a UserControl:
Adding <%@ MasterType VirtualPath="~/MasterPage.master" %>, doesn't work on UserControls. 
So this.Page.Master.MyFunction() fails :(
You have to cast the this.Page.Master first as the Master property of the Page is of type System.Web.UI.MasterPage.
e.g.
((MyMaster)this.Page.Master).MyFunction();
You could check the type of the underlying master page by adding a property to the code behind of the user control:
    public string MType
    {
        get { return this.Page.Master.GetType().FullName; }
    }
and print the result out in the User control markup, e.g. add this line to make it print out as a comment in the source code:
<!-- <%= MType %> //-->
                        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