Question : Access MasterPage Function from UserWebControl Referenced from MasterPage

Hello, I have a master page that has in it a user control.  That web user control needs access to a function that is on the master page.  I looked around and people said to put a reference tag to the master page in the web user control as such:

<%@ Register TagPrefix="mp" TagName="MyMP" Src="~/MasterPages/pubM.master" %>

This seemed like a great idea but it produced the following error:  

Parser Error Message: Circular file references are not allowed.

I think this is because the master page is referencing the user control (code below) and the user control is referencing the master page.

<%@ Register src="../App_Controls/SmallCart.ascx" tagname="SmallCart" tagprefix="uc2" %>

So - how do I do this?  Please, if possible, can the answer be in VB?  I am not that proficient at C#.  

Thanks for your help!

P.S. - I think the big distinction between most people's questions out there on this type of issue is that my User Control is in the master page - not in a content page...

Answer : Access MasterPage Function from UserWebControl Referenced from MasterPage

You can always use reflection...

If your master page has a Method Called test with no params, i.e.:

public void Test()
{
     //Do something
}

Then you can call it like this:
MasterPage myMaster = Page.Master;
myMaster.GetType().GetMethod("Test").Invoke(myMaster, null);
Random Solutions  
 
programming4us programming4us