
270
|
Chapter 12: The Page Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Load
Sub Page_Load(Sender As Object, e As EventArgs)
'code
End Sub
Fired when the page is loaded. Since this event is fired on every page request, we
can add any initialization code that needs to be executed at the page level,
including the initialization of the page’s child controls. When the Load event fires,
the page’s view state information is also accessible.
The Load event is passed the following arguments by ASP.NET:
Sender
An argument containing information about the object that raised the event.
e
An object of type EventArgs containing additional information about the
event.
Example
See the example for Init.
Notes
Note that the Sender and e arguments are optional for this event, as shown in the
example.
When the
AutoEventWireup attribute of the @ Page directive is set to True (the
default), ASP.NET will automatically call the event handler for this event, as long
as it has the correct Page_Load event signature.
Unload
Sub Page_Unload(Sender As Object, e As EventArgs)
'cleanup code
End Sub
Fired when the page is unloaded from memory. Since this event is fired before the
page is unloaded, we can perform cleanup operations, such as closing open files
and database connections.
The Unload event is passed the following arguments by ASP.NET:
Sender
An argument containing ...