title: SharpDevelop - Broken link between .aspx and .aspx.cs files
body: <p>I have just started using <strong>SharpDevelop</strong> and I am trying to convert a <strong>Visual Studio Express</strong> website project into a <strong>SharpDevelop</strong> one.  I managed to create the solution fine and the project within it.  This is a C# ASP.NET webforms project by the way.  Just simple <code>aspx</code> pages with C# codebehinds and an <code>.asmx</code> webservice in there. Nothing special and in fact quite old fashioned stuff, which worked fine in Visual Studio.</p>
  
  <p>I am liking the SharpDevelop environment so please don't answer with "why not use Visual Studio instead" (I have reasons).  But here is my problem:</p>
  
  <p>SharpDevelop is not linking the <code>.aspx</code> files with their <code>.aspx.cs</code> counterparts.  So instead of the solution explorer showing <code>MyPage.aspx</code> which you then expand to see <code>MyPage.aspx.cs</code> under it, you see them as two distinct separate files next to each other and unrelated.</p>
  
  <p>And when I compile the solution I get an error because the codebehind can't tie itself to the aspx page and doesn't recognise the control names.  (Example below is from my Contact.aspx page but it happens on every page where I have any server-side asp.net control).</p>
  
  <pre><code>The name 'EmailAddress' does not exist in the current context (CS0103) - Contact.aspx.cs:52,100
  </code></pre>
  
  <p>Now keep in mind this never used to happen in Visual Studio, so something has gone wrong in my SharpDevelop solution. The error occurs anywhere in the codebehind (.aspx.cs file) which refers to:</p>
  
  <pre><code>EmailComments.Text
  </code></pre>
  
  <p>Things I have already checked:</p>
  
  <p>1) The <code>@Page</code> directive is correct and the <code>Inherits</code> name matches the class name.</p>
  
  <p>2) The .cs and .aspx filenames and class names all match.</p>
  
  <p>3) The .net framework version is <strong>4.5</strong> (does this make a difference?)</p>
  
  <p>4) I have tried explicity declaring the asp.net controls in the codebehind and yes this prevents the error however the link between files remains broken and why should I have to declare the control in the codebehind anyway?  Never used to in Visual Studio and it worked fine there.</p>
  
  <p>Wierdly there is one file in my entire solution which does not have this problem (the aspx and aspx.cs files are linked fine) and this is the <code>default.aspx</code> page.  There is nothing different about it.  The only thing I can see is that it's a lowercase filename whereas the others are mixed case.  (Surely that's not relevant?)</p>
  
  <p>I would really appreciate help from anyone familiar with <strong>SharpDevelop</strong> or if it's a more general .net issue then please tell me.  I feel as if there is some basic thing I am forgetting that will make this work.</p>
  
  <p>Thank you very much for any help.</p>
  
  <p>UPDATE: I have managed to link the .aspx and .aspx.cs files by doing the following: Drag and drop the .aspx.cs file on to the .aspx file in the solution explorer.  Do this for every pair of files.  Then save and close the solution and re-open and they remain linked.  BUT, the error remains as per above because the codebehind does not recognise the controls referred to in it.</p>