In the brave new world of ASP.NET 2.0 AKA Whidbey the seperation between markup and code has changed. In ASP.NET 1.x the developer typically created a code-behind page (C#, VB.NET) and an ASP.NET mark-up page (.aspx) that inherited from it. Control declarations (and event handlers in C#) where declared and wired up in a region of the code-behind file that VS.NET kept “in synch” (well…tried to keep in synch) with your .aspx markup page. The new way uses partial types (new compiler features in VB.NET /C#) *. When your page is compiled (either pre-compiled or first viewed) the ASP.NET runtime creates a partial type that contains the variable declarations for your page (and any inline <% %> style code you have too). If you have specified a partial type with your page (via the CompileWith @Page directive) then this file and the partial type that ASP.NET created are munged into a single class (well, that is how I understand it all to be taking place anyway ).
An interesting question I wondered was, how do my event handlers get wired up? In VS 2005 event handlers for VB.NET did not have any “Handles” directive after them, and C# does not have the option to wire up it’s event handlers this way, so how was it being done? The answer lies in one of the stranger @Page directives in ASP.NET - the AutoEventWireUp directive. VS.NET 2002⁄3 always set this to false by default, and you could see some weird “event handlers being called twice“ behavior if you unintentionally removed it but kept your event hander wire up code. It seems that ASP.NET 2.0 uses them by default instead of using “Handles“ or attaching event handlers elsewhere. I never really understood the purpose of the AutoEventWireUp directive to begin with. You could possibly make a case for it being a “convenience“ feature, so please leave a comment if you know why it exists.
* Note: I keep reading from time to time that partial types are a CLR feature. I’m pretty sure partial types are a compiler feature, but I keep hearing the “CLR feature” story from so many places that I have begun do doubt my correctness on this one.
All this is, of course to the best of my very incomplete knowledge while examining the workings of a pre-beta product. YMMV, contents may have shifted during transport, actual colour may differ from those shown etc.. etc..