i

ASP.Net A Complete Guide

Code-Behind

In this mode, Design, part and code part will be maintained in a separate file. It helps to maintain and debug the application. It has the extension like .aspx.cs or .aspx.vb depending on the language used. It helps to maintain the HTML separate from the business logic. In code-behind file class can be created and which is derived from the page class. That page class then serve as the base class for the associated web page.

This relationship between the class and the web page is established by a Page directive in the .aspx file:

  < %@ Page inherits="MyPage" % >

The inherits attribute help to identify that the class is created in the code-behind file from which this .aspx file will derive.