title: ASPX Accessing master page function
body: <p>I am trying to access a function placed in master page code-behind from another ASPX page as follows.</p>
  
  <p>Main.master.cs:</p>
  
  <pre><code>public partial class Main : System.Web.UI.MasterPage
  {
      protected void Page_Load(object sender, EventArgs e)
      {
        ...
      }
  
      public static bool test()
      {
          return true;
      }
  }
  </code></pre>
  
  <p>Product.aspx:</p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/Main.master" EnableEventValidation="false"
  AutoEventWireup="true" ValidateRequest="false" CodeFile="Product.aspx.cs" Inherits="Common_Product" Title="Product" %&gt;
  ...
  &lt;asp:Label id="test123" runat="server" /&gt;
  </code></pre>
  
  <p>Product.aspx.cs:</p>
  
  <pre><code>using SiteABC.Accelerate;
  public partial class Common_Product : SiteABC.Accelerate.SerializePageViewState   
  {
      private void Page_Load(Object sender, EventArgs e)
      {
          Main cm = (Main)Page.Master; 
          test123.Text = "yo | " + cm.test();
      }
  }
  </code></pre>
  
  <p>This results in a compiler error:</p>
  
  <pre><code>Compiler Error Message: CS0176: Member 'Main.test()' cannot be accessed with an instance reference; qualify it with a type name instead
  </code></pre>
  
  <p>What is wrong in this scenario?</p>
  
  <p>Thank you.</p>