From quickstart:
Simplified Code Behind Model New in 2.0ASP.NET 2.0 introduces an improved runtime for code-behind pages that simplifies the connections between the page and code. in this new code-behind model, the page is declared as a partial class, which enables both the page and code files to be compiled into a single class at runtime. the page code refers to the code-behind file in the CodeFile attribute of the <% @ Page %> directive, specifying the class name in the Inherits attribute. note that members of the code behind class must be either public or protected (they cannot be private ).
C # CodeBehind Code Separation
The advantage of the simplified code-behind model over previous versions is that you do not need to maintain separate declarations of server control variables in the code-behind class. using partial classes (new in 2.0) allows the server control IDs of the ASPX page to be accessed directly in the code-behind file. this greatly simplifies the maintenance of code-behind pages.
This is indeed an improvement for development. Removing the server control statement in CodeBehind will make the code "refreshing" a lot, and it looks much more comfortable. See the example:
This is indeed an improvement for development. Removing the server control statement in CodeBehind will make the code "refreshing" a lot, and it looks much more comfortable. See the example:
We place a textbox on the page:
Test. aspx
<% @ Page language = "C #" CodeFile = "Test. aspx. cs" Inherits = "Test_aspx" %>
<Html>
<Head>
<Title> Test ASP. NET 2.0 </title>
</Head>
<Body>
<Form runat = "server">