Skip to Content
Programming Visual Basic .NET
book

Programming Visual Basic .NET

by Dave Grundgeiger
December 2001
Beginner
464 pages
13h 51m
English
O'Reilly Media, Inc.
Content preview from Programming Visual Basic .NET

Handling Page Events

The base Page class may at times raise events. These events can be handled by the derived Page class (the code-behind class) or by code embedded in the web page. Although it’s possible to define an event-handler subroutine, the preferred response to events raised by the Page class is to override the protected methods provided by the Page class. For example, the following method could be placed in the code-behind class, providing a way to respond to the loading of the page:

Protected Overrides Sub OnLoad(e As EventArgs)
   MyBase.OnLoad(e)
   ' ...
End Sub

Warning

When overriding an OnEvent-style method, ensure that the overriding method calls the base-class implementation, in addition to its own processing. The job of the base-class implementation is to raise the corresponding event. If the base-class implementation is not called, the event won’t be raised.

Following is the list of events a Page object might raise. The Page class itself doesn’t define these events: it inherits them from its parent classes. This list of events includes a brief description of each event, the class in which the event is defined, and the syntax for overriding the protected method that corresponds to the event.

AbortTransaction (inherited from System.Web.UI.TemplateControl)

Raised when a COM+ transaction in which the page is participating is aborted. Its syntax is:

    Protected Overrides Sub OnAbortTransaction(ByVal e As EventArgs)
CommitTransaction (inherited from System.Web.UI.TemplateControl) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Visual Basic .NET, Second Edition

Programming Visual Basic .NET, Second Edition

Jesse Liberty

Publisher Resources

ISBN: 0596000936Supplemental ContentCatalog PageErrata