The MS ASP.NET Web Matrix app does things quite a bit differently than Visual Studio.NET. The Matrix seems to be a little more along the lines of what old-timer ASP 3 programmers expect. I jumped right in and turned off option explicit and turned vb strict to false and started inline coding with poor case and without dim statements. Woohoo!

Of course the devil's in the details. I tried to take some of the code I'd Matrixed (where they got that name, I'm not sure) and push it into VS.NET. Nothing. My DataGrid code I'd added in the Matrix was going nowhere.

Here's the rub -- from MS's .NET help (found here if you're on Windows and have .NET installed).
Alternatively, the ASP.NET page framework also supports an automatic way to associate page events and methods. If the AutoEventWireup attribute of the Page directive is set to true (or if it is missing, since by default it is true), the page framework calls page events automatically, specifically the Page_Init and Page_Load methods. In that case, no explicit Handles clause or delegate is needed.

The disadvantage of the AutoEventWireup attribute is that it requires that the page event handlers have specific, predictable names. This limits your flexibility in how you name your event handlers. Therefore, in Visual Studio, the AutoEventWireup attribute is set to false by default and the designer generates explicit code to bind page events to methods.

If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events and the page framework will automatically call events based on their names. This can result in the same event code being called twice when the page runs. As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.


If you use VB 6 (where I do use Option Explicit so as not to drive myself mad -- ASP means all the code is [more or less] on the same page; VB 6 is another story), you're used to wacky names for subs like "cmdSmack_Click()" to handle, in this case, button click events. If you came to VB from Java, you wondered how in the world VB knew to call that sub when cmdSmack was clicked without any code to link the two; there was no "ActionListener" or anything of the sort. Wow! A whole layer of overhead just disappeared!

Of course changing the sub's name breaks things. And, quite strangely, adding a sub named "cmdSmack_Click" by hand "out of the blue" still makes that code happen when you click the button. Where's the glue? Holding the event handler to the sub?

There is no glue in VB 6 (or rather, the glue's always there, just invisible), and there's no glue in an ASP.NET page made by VS.NET by default. But if you set AutoEventWireup to true in your asp.net page in VS.NET, all you have to do is write a sub "Page_Load(Source As Object, E As EventArgs)" and your code is executed with each load. In the Matrix, wireup's going to happen by default.

Just to say that comparing the two IDEs makes it clear that Microsoft has a couple of different camps as to what's the "right" way to code files. Or, at the very least, they recognize there are at least two camps on how to do things right in the world of ASP.NET programmers.

Big shops use VS.NET and separate GUI from logic and can utilize a more robust language like C#, small timers can get back to quick scripting like they're used to doing with the Matrix, vb.net, and a few hard-line compatibilities turned off.