OdeToCode IC Logo

VB.NET versus C# Web Forms

Sunday, July 17, 2005

There is a subtle difference in the default ASP.NET 2.0 ASPX files for VB and C#. I mention the difference only because C# is traditionally the ‘explicit’ language while VB.NET is the language with late binding features built-in.

A new VB.NET web form places AutoEventWireup=”false” in it’s @ Page directive. This means your code is responsible for explicitly wiring up Page events.

A new C# web form places AutoEventWireup=”true” in it’s @Page directive. This means the runtime will reflect upon your code to find method names in the form of Page_EventName and attach the methods as event handlers for named event.

Why is this?

VB.NET’s Handles keyword allows you to catch an event in a declarative manner. There is no comparable feature in C#. It’s a nice feature to have.