One of our contractors gave us an ASP.NET 2.0 web site and I'm having a little trouble integrating it into our process. He gave us the project as a zipped directory, no solution file or anything. I can open it in Visual Studio using the Open -> Website option, and the website runs. However, I wanted to set it up as a web application project so that I could add project references to our shared libraries instead of them being linked into the 'bin' directory, and just because I'd prefer to have a regular project really.
I'm running into a weird issue. Let me extract a little code:
HeaderControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeaderControl.ascx.cs" Inherits="Controls_WebUserControl" %>
HeaderControl.ascx.cs
public partial class Controls_WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
Ok, this is a little strange but it seems to be legal at least. The base class has a partial definition in the code-behind (code file?). But then many other controls are defined in the same way, eg
SomeControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SomeControl.ascx.cs" Inherits="Controls_WebUserControl" %>
SomeControl.ascx.cs
public partial class Controls_WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
Expectedly, when I try to build my new web application project that I've transferred the files into I get a bunch of errors about the same method being defined in several places. I don't understand why it's not set up with a code behind defining a partial definition of the control class and overriding methods of the base class, but that's sort of beside the point.
What really gets me is this: How does the original work? It runs and it works, so the compiler must be doing something that I don't understand. What happens to the Controls_WebUserControl class?