
52
|
Chapter 3: Web Forms
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
PreRender
The PreRender event is fired just before the page (or control) is rendered and
sent to the client. The PreRender event is the last chance for page output to be
modified before it is sent to the browser. It is also the last event that fires before
the ViewState of the controls on the page is saved, so any control changes you
wish to have saved to ViewState should be made either before or during this
event. ViewState is discussed more fully in the “State Management” section in
this chapter. The PreRender event is also the last opportunity for registering
client-side script blocks using the helper methods of the Page class (such as
Page.RegisterClientScriptBlock).
Unload
The Page_Unload event is fired after the page is rendered. You can use the Page_
Unload event handler to write cleanup code.
For example, in the following snippet, the database connection objConnection is
closed:
Sub Page_Unload(sender As Object, e As EventArgs )
' Close the database connection
objConnection.Close( )
End Sub
State Management
In a typical web page, it is very common for data entry forms to retain their values
after the form has been posted and the same page is returned to the client (that is,
to retain the values from a posted form in the postback). To implement this
feature in ...