How to call a parent class's method from child class in c#?
<p>I have a master page with a method I use a lot from content page code behinds. In those code behinds, I have a method that gets duplicated a lot, so I thought I'll put it in something I can inherit from. Unfortunately, I now can't call the method in my master page code behind from the base class. I think I should know how and I'm probably being pretty stupid today but I can't figure it out.</p>

<p>Here's some code! Please ignore any howling errors, I just typed this off the top of my head :)</p>

<p><strong>Master Page Code-behind</strong></p>

<pre><code>public partial class Site : MasterPage
{
    public void MyMethod()
    {
        // Do Something...
    }
}
</code></pre>

<p><strong>Content (Child) Page</strong></p>

<p><em>Declarative</em></p>

<pre><code>&lt;%@ MasterType VirtualPath="~/Site.Master" %&gt;
</code></pre>

<p><em>Code-behind</em></p>

<p>Works</p>

<pre><code>public class Test : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Master.MyMethod();
    }
}
</code></pre>

<p>Does Not Work</p>

<pre><code>public class Test : TestClass
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OtherMethod();
    }
}

public class TestClass : Page
{
    public void OtherMethod()
    {
        this.Master.MyMethod();
    }
}
</code></pre>

<p>Now, looking at it, I intuitively know "this.Master" can't work but I don't have any lightbulbs going off for an answer. How do I get the reference to my master page method back?</p>

<p>Thanks,
Richard</p>
