Lab 2 Code Implementation

This code demonstrates the ASP.NET Page Life Cycle using simple event handlers.

<%@ Page Language="VB" %>
<script runat="server">
    Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
        Response.Write("<br/>[Page_Init] The page is initializing...<br/>")
    End Sub

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Response.Write("[Page_Load] The page is loading data and controls...<br/>")
    End Sub

    Sub Page_PreRender(ByVal sender As Object, ByVal e As EventArgs)
        Response.Write("[Page_PreRender] The page is almost ready to render to the client...<br/>")
    End Sub

    Sub Page_Unload(ByVal sender As Object, ByVal e As EventArgs)
        ' Note: Response.Write does not work here
    End Sub
</script>

<html>
<head><title>Lab 2 Demonstration</title></head>
<body>
    <h2>ASP.NET Page Life Cycle Events</h2>
</body>
</html>