title: Create partial classes in Asp.Net
body: <p>I have a small web application.</p>
  
  <p>This is what I want to do: Create partial classes to split up a code behind file.
  Why am I not able to create partial classes directly?</p>
  
  <p>If this is the codebehind file:</p>
  
  <pre><code>using System;
  using System.Configuration....
  
  
  public partial class _Default : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          Test();
      }
  }
  </code></pre>
  
  <p>And also create this class:</p>
  
  <pre><code>public partial class _Default
  {
      public void Test()
      {
      }
  }
  </code></pre>
  
  <p>I get an error message, Test doesn't exists in current context.</p>
  
  <p>Why is this?</p>
  
  <p>I get everything to work if I create a couple of partial classes which inherits from System.Web.UI.Page and then inherit my codebehind file from this class (the result of the partial classes). Is this the only way?</p>
  
  <p>Has is something to do with that the codebehind and the aspx-page is dynamically compiled into a class?</p>
  
  <p>Would appreciate if anyone could answer my problem. Things are working out right now but I would prefer to create the partial classes at the same "level" as the codebehind and avoid to use inheritance.</p>
  
  <p>Thank you /John</p>
  
  <p>(note that I have underscore in front of both classes but only one is visible in the preview, I don't know why..)</p>