<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="PageFlowTracing" Trace="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Page Flow</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label id="lblInfo"
runat="server" EnableViewState="False"/>
<asp:Button id="Button1"
runat="server"
Text="Button" OnClick="Button1_Click"/>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class PageFlowTracing : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
lblInfo.Text += "Page.Load event handled.<br/>";
if (Page.IsPostBack)
{
lblInfo.Text += "<b>This is the second time you've seen this page.</b><br/>";
}
}
private void Page_Init(object sender, System.EventArgs e)
{
lblInfo.Text += "Page.Init event handled.<br/>";
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Trace.Write("Button1_Click", "About to update the label.");
lblInfo.Text += "Button1.Click event handled.";
Trace.Write("Button1_Click", "Label updated.");
}
private void Page_PreRender(object sender, System.EventArgs e)
{
lblInfo.Text += "Page.PreRender event handled.<br/>";
}
private void Page_Unload(object sender, System.EventArgs e)
{
lblInfo.Text += "Page.Unload event handled.<br/>";
}
}
|