
Structuring an ASP.NET Page | 43
Web Forms
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
As you can see by comparing Examples 3-1 and 3-2, the Label server control has
been modified to become the HTML
<span> tag. Also notice that a hidden form
field stores the state of the Label server control.
Code-Behind Files
ASP.NET promotes the separation of code and content. The use of code-behind
files is one of the mechanisms that aides the separation of the UI and the UI logic.
Developing an ASP.NET page using code-behind files requires two steps:
1. Developing the page’s UI using HTML and web controls.
2. Developing the UI logic (code-behind) using any of the .NET languages.
A code-behind file consists of a class inherited from the Page class. It provides an
object-oriented way of developing the UI logic of an ASP.NET page. The code-
behind file has member variables, event handlers, and helper methods that are
called from the event handlers specific to an ASP. NET page. The ASP.NET page
and the code-behind file are tightly coupled, meaning that changes in one usually
often require the other to be changed in order for both to function correctly.
Fortunately, when developing pages using code-behind in Visual Studio .NET,
most of this is taken care of for you.
The extension of the code-behind file varies depending upon the .NET program-
ming language ...