Custom events firing last

M

mpaine

I have read
http://msdn2.microsoft.com/en-us/library/ms178472(VS.80).aspx and my
interpretation is that custom events should be fired between Page_Load
and Page_LoadComplete. When I run the following sample code, the
custom events are always last. Why is that?

Your help will be greatly appreciated!

<%@ Page Language="VB" AutoEventWireup="false" Title="Test ASP.NET Life
Cycle"
EnableEventValidation="false" %>

<script language="vb" runat="server">
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text = "PreLoad" & "<br/>"
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "Load" & "<br/>"
End Sub

Protected Sub Submit_OnCommand(ByVal sender As Object, ByVal Args
As CommandEventArgs)
test.Text &= "OnCommand" & "<br/>"
End Sub

Protected Sub Reload_OnCommand(ByVal sender As Object, ByVal Args
As CommandEventArgs)

Response.Redirect(HttpContext.Current.Request.ServerVariables("SCRIPT_NAME"))
End Sub

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "LoadComplete" & "<br/>"
End Sub

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "PreRender" & "<br/>"
End Sub
</script>

<HTML>
<body>
<form id="aForm" runat="server">
<asp:Button ID="Reload" runat="server" Text="Reload"
runat="server"
UseSubmitBehavior="true" EnableViewState="true"
OnCommand="Reload_OnCommand"
CommandArgument=''
CommandName="reload" /><br />
<asp:Button ID="Submit" runat="server" Text="Submit"
runat="server"
UseSubmitBehavior="true" EnableViewState="true"
OnCommand="Submit_OnCommand"
CommandArgument=''
CommandName="post" /><br />
<asp:Label ID="test" runat="server"></asp:Label>
</form>
</body>
</HTML>
 
M

mpaine

I just noticed that child controls are rendered after page controls.
Still, Submit_Unload is called before Submit_OnCommand. Why is that?
Here is my updated test code:

<%@ Page Language="VB" AutoEventWireup="false" Title="Test ASP.NET Life
Cycle"
EnableEventValidation="false" %>

<!-- http://msdn2.microsoft.com/en-us/library/ms178472(VS.80).aspx says
LoadComplete should fire after OnCommand but it doesn't -->

<script language="vb" runat="server">
Protected Sub Page_PreLoad(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text = "PreLoad" & "<br/>"
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "Load" & "<br/>"
End Sub

Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "LoadComplete" & "<br/>"
End Sub

Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "PreRender" & "<br/>"
End Sub

Protected Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "Unload" & "<br/>"
End Sub

Protected Sub Submit_OnCommand(ByVal sender As Object, ByVal Args
As CommandEventArgs)
test.Text &= "OnCommand" & "<br/>"
End Sub

Protected Sub Submit_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "Submit_Load" & "<br/>"
End Sub

Protected Sub Submit_LoadComplete(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.PreLoad
test.Text &= "Submit_LoadComplete" & "<br/>"
End Sub

Protected Sub Submit_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreLoad
test.Text &= "Submit_Unload" & "<br/>"
End Sub

Protected Sub Reload_OnCommand(ByVal sender As Object, ByVal Args
As CommandEventArgs)

Response.Redirect(HttpContext.Current.Request.ServerVariables("SCRIPT_NAME"))
End Sub
</script>

<HTML>
<body>
<form id="aForm" runat="server">
<asp:Button ID="Reload" runat="server" Text="Reload"
UseSubmitBehavior="true" EnableViewState="true"
OnCommand="Reload_OnCommand"
CommandArgument=''
CommandName="reload" /><br />
<asp:Button ID="Submit" runat="server" Text="Submit"
UseSubmitBehavior="true" EnableViewState="true"

OnCommand="Submit_OnCommand"
CommandArgument=''
CommandName="post" /><br />
<asp:Label ID="test" runat="server"></asp:Label>
</form>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top