Click here to Skip to main content
Click here to Skip to main content

Tagged as

Tracking page events in ASP.NET Page

, 2 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A simple way to track the sequence ASP.NET page events.
This is a simple way to track the page events in ASP.NET, I used it to follow the sequence of raising events, also it can be used as a debugging methodology.
  1. First when you create a new asp.net page add this code:
    Dim SeqNo As Integer = 0
     
        Private Sub Page_AbortTransaction(sender As Object, e As System.EventArgs) Handles Me.AbortTransaction
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " - AbortTransaction")
        End Sub
     
        Private Sub Page_CommitTransaction(sender As Object, e As System.EventArgs) Handles Me.CommitTransaction
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " - CommitTransaction")
        End Sub
     
        Private Sub Page_DataBinding(sender As Object, e As System.EventArgs) Handles Me.DataBinding
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  DataBinding")
        End Sub
     
        Private Sub Page_Disposed(sender As Object, e As System.EventArgs) Handles Me.Disposed
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  Disposed")
        End Sub
     
        Private Sub Page_Error(sender As Object, e As System.EventArgs) Handles Me.Error
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  Error")
        End Sub
     
        Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  Init")
        End Sub
     
        Private Sub Page_InitComplete(sender As Object, e As System.EventArgs) Handles Me.InitComplete
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  InitComplete")
        End Sub
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  Load")
        End Sub
     
        Private Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  LoadComplete")
        End Sub
     
        Private Sub Page_PreInit(sender As Object, e As System.EventArgs) Handles Me.PreInit
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  PreInit")
        End Sub
     
        Private Sub Page_PreLoad(sender As Object, e As System.EventArgs) Handles Me.PreLoad
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  PreLoad")
        End Sub
     
        Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  PreRender")
        End Sub
     
        Private Sub Page_PreRenderComplete(sender As Object, e As System.EventArgs) Handles Me.PreRenderComplete
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  PreRenderComplete")
        End Sub
     
        Private Sub Page_SaveStateComplete(sender As Object, e As System.EventArgs) Handles Me.SaveStateComplete
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  SaveStateComplete")
        End Sub
     
        Private Sub Page_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
            SeqNo += 1
            Debug.Print(SeqNo.ToString & " -  Unload")
        End Sub
    • Run the Web application in Debug mode (by selecting Debug-> Start Debugging OR press F5).
    • After the page is viewed completely on the browser, check the output window in Visual Studio (if it was not opened select View -> Output OR press Ctrl+Alt+O)
    • you will see something like this:
(removed text )....
  1. PreInit
  2. Init
  3. InitComplete
  4. PreLoad
  5. Load
  6. LoadComplete
  7. PreRender
  8. PreRenderComplete
  9. SaveStateComplete
  10. Unload
( removed text )....

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mohammed Derbashi
Architect
Jordan Jordan
No Biography provided
Follow on   Twitter

Comments and Discussions

 
Generalnice but could we ca nmake a single call for asll of the web... Pinmemberdineshkummarc18-Nov-11 0:34 
GeneralReason for my vote of 5 nice & simple.. Pinmemberitaitai3-Oct-11 23:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 2 Oct 2011
Article Copyright 2011 by Mohammed Derbashi
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid