The code-behind class for a page is derived from BaseApplicationPage class.
This class contains methods that can be modified and some methods that should not be modified. The methods that can be modified are in a region called Section 1 while Section 2 methods should not be modified.
The name of the code-behind class is the same as the name of the page. For example, a page named ShowCustomerTablePage will have a code-behind code-behind class called ShowCustomerTablePage. Since the name of the page is used as the name of the class, all page names must be unique in the application regardless of where they are located.
The code-behind classes are generated in the namespace’s UI sub-namespace you provide when creating the application. For example, if your namespace is specified as MyApp, the code-behind class is generated in MyApp.UI.
In addition to the generated methods, this class also performs the following:
Registers event handlers for each of the controls on the page.
Defines properties and methods to provide easy access to the controls.
A variable and public property is defined to access the control.
Protected WithEvents AuthorLastName As BaseClasses.Web.UI.WebControls.FieldValueTextBox
Public ReadOnly Property AuthorLastName() As BaseClasses.Web.UI.WebControls.FieldValueTextBox
Get
Return Me.AuthorLastName
End Get
End Property
Protected WithEvents declarations allow event handler methods to be associated with the declared server controls' server-side events. These associations are established by using the Handles keyword and the declared WithEvents variable in the declaration(s) of eligible methods.
All server control tags in an ASPX/ASCX have a "Protected WithEvents" declaration in the code-behind, except:
Server control tags contained inside of a templated server control's start and end tags (e.g. inside of an <ItemTemplate> or a Repeater control) declared in the same ASPX/ASCX.