asp.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.