In ASP.NET 1.1, the attribute name was CodeBehind, but in ASP.NET 2.0 and later,
the attribute is CodeFile. The CodeFile attribute points to the location of the class file, and the
Inherits attribute specifies the class name the .ascx tag page inherits from. The CodeFile attribute
for the @Control (and the @Page) directive in conjunction with the partial class declaration in
54 CHAPTER 2 ?– ENCAPSULATING FUNCT IONALITY IN A SP.NET
the code-behind file is part of the new code-behind model in ASP.NET 2.0 and later. The model
also removes the requirement to have protected declarations of all server controls used on a
web form or user control page in the code behind file, removing what was a fragile relationship
in ASP.NET 1.1 between the .aspx/.ascx page and the code-behind file, as well as generally
making the code-behind files cleaner and shorter.
?– Note The partial class model applies only if the CodeFile attribute exists in the @Page or @Control
directive. If the Inherits or src attribute is used without the CodeFile attribute, ASP.NET 2.0 and later
resorts to ASP.NET 1.1 code-behind style and places the class as the sole base class for the .aspx or .ascx
file. If there isn??™t a code-behind file, class generation is also similar to ASP.
Pages:
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115