Chapter 6. Programming Web Forms
In Chapter 5, you learned many of the details about using ASP server controls in Web Forms. In this chapter, you will learn techniques to help you utilize the full power of ASP.NET in creating Web Forms, including:
Using code-behind to segregate the presentation code from the logic
Understanding the control lifecycle of a web page
Managing state in ASP.NET
Using Visual Studio .NET as a development tool
In traditional ASP, the interweaving of script with HTML can produce
source control nightmares and difficult-to-maintain ASP pages.
ASP.NET addresses this problem by giving programmers the ability to
separate the executable code
from the presentation code. You write the HTML in a
(with a .
and you write the C# or VB.NET code in
file (with a
extension, depending on its language), which is another way of saying
the “code file behind the form.”
In the code-behind file, you create a
can be any class derived from the Page class) that serves as the base
class for the web page you create in the
file. This relationship between your class and the web page is
established by a
directive at the top of the
<%@ Page inherits="CodeBehindDemo" %>
the class created in the code-behind file from which this
.aspx file will derive.
When a web form is compiled, its page is parsed and a new class is generated and compiled. This new class derives ...