Here is my code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="InitLoad.aspx.vb"
Inherits="WebApplication1.InitLoad"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>InitLoad</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="
http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="lblInitStatus" runat="server"
EnableViewState="False">Fired Init Event: </asp:Label><BR>
<asp:Label id="lblLoadStatus" runat="server"
EnableViewState="False">Fired Load Event: </asp:Label><BR>
<BR>
<asp:Button id="btnResetStatus" runat="server" Text="Reset Init &
Load Status" Font-Bold="True"
Width="168px" EnableViewState="False"></asp:Button><BR>
<BR>
<asp:Button id="btnDoAPostback" runat="server" Text="Do A Postback"
Font-Bold="True" Width="104px"
EnableViewState="False"></asp:Button>
</form>
</body>
</HTML>
Public Class InitLoad
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents lblInitStatus As System.Web.UI.WebControls.Label
Protected WithEvents lblLoadStatus As System.Web.UI.WebControls.Label
Protected WithEvents btnResetStatus As System.Web.UI.WebControls.Button
Protected WithEvents btnDoAPostback As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
lblInitStatus.Text &= "FIRED"
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lblLoadStatus.Text &= "FIRED"
End Sub
Private Sub btnResetStatus_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnResetStatus.Click
lblInitStatus.Text = "Fired Init Event: "
lblLoadStatus.Text = "Fired Load Event: "
End Sub
Private Sub btnDoAPostback_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDoAPostback.Click
If btnDoAPostback.BackColor.Equals(Color.Silver) Then
btnDoAPostback.BackColor = Color.Black
btnDoAPostback.BorderColor = Color.Black
btnDoAPostback.ForeColor = Color.Silver
Else
btnDoAPostback.BackColor = Color.Silver
btnDoAPostback.BorderColor = Color.Silver
btnDoAPostback.ForeColor = Color.Black
End If
End Sub
End Class
This code has two Labels and two Buttons. The two Labels let you know
whether the Init and Load events were fired. The first button resets the
Labels, and the second Button is used to perform a postback (I simply have
the button invert its BackColor and ForeColors). However, the Init event is
fired every time.