By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,022 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,022 IT Pros & Developers. It's quick & easy.

Custom events firing last

P: n/a
I have read
http://msdn2.microsoft.com/en-us/lib...72(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.Serv erVariables("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>

Dec 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/lib...72(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.Serv erVariables("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>

mp****@htxml.com wrote:
I have read
http://msdn2.microsoft.com/en-us/lib...72(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.Serv erVariables("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>
Dec 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.