Tips and Tricks in a world of Mix

From http://www.asp.net/general/videos/page-lifecycle-events
A bit about the order in the asp.net forms




Public Class _Default
Inherits System.Web.UI.Page


Private Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
'if ths post is a postback we can check the IsPostback property
'if this is a Postback the user controls hasn't been reconstituted from the viewstate yet
'set things that are global to the page
'dynamicly set a master page or a theme property , desision based on a geography or a time
'profile property
'dynamicly added controls by a logic
End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
'rewrite any specific control properties
End Sub

Private Sub Page_InitComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.InitComplete
'after all of the initialazation took place
'logic that depends on the controls initialized
End Sub

Private Sub Page_PreLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad
'pre loads for all of the controls are being fired
'after this viewstate is being initialized
'all of the post back data is being initialized from the postback
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'any child control event implemented is being fired
End Sub

Private Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
'any task that requires all of the controls on the page to be loaded and validated
End Sub


Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
'final changes to controls before its becoming the html
End Sub


Private Sub Page_SaveStateComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SaveStateComplete
'viewstate has been saved
'won't be rendered to the page
'can apply some logic that requires the viewstate to be completed
End Sub

Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
'been rendered
'final cleanups
'after proccessing
'close any files
'release any db connecions
End Sub
End Class

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: