Develop a page to demonstrate various events which are raised and handled during ASP.NET Page processing once the page object has been created?
CODE BEHIND FILE
Partial Class _Default
Inherits System.Web.UI.Page
Private Sub form1_Init(sender As Object, e As EventArgs) Handles form1.Init
If IsPostBack Then
Label1.Text &= "<br/>Page Initialization Event Occurred (PostBack)<br/>"
Else
Label1.Text &= "<br/>Page Initialization Event Occurred (First Load)<br/>"
End If
End Sub
Private Sub form1_Load(sender As Object, e As EventArgs) Handles form1.Load
If IsPostBack Then
Label1.Text &= "Page Load Event Occurred (PostBack)<br/>"
Else
Label1.Text &= "Page Load Event Occurred (First Load)<br/>"
End If
End Sub
Private Sub form1_PreRender(sender As Object, e As EventArgs) Handles form1.PreRender
If IsPostBack Then
Label1.Text &= "Page PreRender Event Occurred (PostBack)<br/>"
Else
Label1.Text &= "Page PreRender Event Occurred (First Load)<br/>"
End If
End Sub
Private Sub form1_Unload(sender As Object, e As EventArgs) Handles form1.Unload
' Label1 text won't be visible here, included just for completeness
If IsPostBack Then
Label1.Text &= "Page Unload Event Occurred (PostBack)<br/>"
Else
Label1.Text &= "Page Unload Event Occurred (First Load)<br/>"
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If IsPostBack Then
Label1.Text &= "Button Click Event Occurred (PostBack)<br/>"
Else
Label1.Text &= "Button Click Event Occurred (First Load - unexpected)<br/>"
End If
End Sub
End Class

DEFAULT.ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" Width="80px" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Page Events"></asp:Label>
<br />
</div>
</form>
</body>
</html>

This is the very first event that happens when a page is requested. It sets up the page's controls, but the page is not yet visible to the user.
After initialization, this event occurs. It's where the page starts getting loaded with data, user controls, and any initial content. It's like the page being filled with all the necessary information.
This event occurs just before the page is rendered (or sent) to the user's browser. At this point, html page is generated.
After the page has been rendered and the user is done with it, this event is triggered to clean up and release any resources. The label string in the unload event handler does not get displayed because the html page gets rendered before the page unload event.
This event is separate from the page lifecycle. It occurs when the user interacts with a button on the page. When the button is clicked, the request is sent to the server where the page is loaded again, (the page initialization event only occurs for the first time the page is requested) then the event handler for button click runs. After this the page prerender events occur. After page unload event the rendered page is displayed on the web.