Writing Code Behind a Web Form

In the Web Forms programming model, you have a choice of where to put the VB code; it can reside with the HTML in an .aspx file (as described in Chapter 17, “Using Active Server Pages.NET”), or in a separate .vb file that contains just code. Keeping the code and user interface separate is one of the great features of the Web Forms programming model, so Visual Studio .NET makes this choice for you by creating a webformname .aspx.vb file automatically when you add a new Web form to your project. This separate file is known as the code-behind file, because it contains the code “behind” the Web form interface.

Visual Studio makes the fact that there are two files transparent to the developer; choosing View Code in ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.