473,769 Members | 3,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom events firing last

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_LoadComple te. 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"
EnableEventVali dation="false" %>

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

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

Protected Sub Submit_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)
test.Text &= "OnCommand" & "<br/>"
End Sub

Protected Sub Reload_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)

Response.Redire ct(HttpContext. Current.Request .ServerVariable s("SCRIPT_NAME" ))
End Sub

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text &= "LoadComple te" & "<br/>"
End Sub

Protected Sub Page_PreRender( ByVal sender As Object, ByVal e As
System.EventArg s) 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"
UseSubmitBehavi or="true" EnableViewState ="true"
OnCommand="Relo ad_OnCommand"
CommandArgument =''
CommandName="re load" /><br />
<asp:Button ID="Submit" runat="server" Text="Submit"
runat="server"
UseSubmitBehavi or="true" EnableViewState ="true"
OnCommand="Subm it_OnCommand"
CommandArgument =''
CommandName="po st" /><br />
<asp:Label ID="test" runat="server"> </asp:Label>
</form>
</body>
</HTML>

Dec 1 '06 #1
1 1775
I just noticed that child controls are rendered after page controls.
Still, Submit_Unload is called before Submit_OnComman d. Why is that?
Here is my updated test code:

<%@ Page Language="VB" AutoEventWireup ="false" Title="Test ASP.NET Life
Cycle"
EnableEventVali dation="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(By Val sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text = "PreLoad" & "<br/>"
End Sub

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

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text &= "LoadComple te" & "<br/>"
End Sub

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

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

Protected Sub Submit_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)
test.Text &= "OnCommand" & "<br/>"
End Sub

Protected Sub Submit_Load(ByV al sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text &= "Submit_Loa d" & "<br/>"
End Sub

Protected Sub Submit_LoadComp lete(ByVal sender As Object, ByVal e
As System.EventArg s) Handles Me.PreLoad
test.Text &= "Submit_LoadCom plete" & "<br/>"
End Sub

Protected Sub Submit_Unload(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text &= "Submit_Unl oad" & "<br/>"
End Sub

Protected Sub Reload_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)

Response.Redire ct(HttpContext. Current.Request .ServerVariable s("SCRIPT_NAME" ))
End Sub
</script>

<HTML>
<body>
<form id="aForm" runat="server">
<asp:Button ID="Reload" runat="server" Text="Reload"
UseSubmitBehavi or="true" EnableViewState ="true"
OnCommand="Relo ad_OnCommand"
CommandArgument =''
CommandName="re load" /><br />
<asp:Button ID="Submit" runat="server" Text="Submit"
UseSubmitBehavi or="true" EnableViewState ="true"

OnCommand="Subm it_OnCommand"
CommandArgument =''
CommandName="po st" /><br />
<asp:Label ID="test" runat="server"> </asp:Label>
</form>
</body>
</HTML>

mp****@htxml.co m 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_LoadComple te. 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"
EnableEventVali dation="false" %>

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

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

Protected Sub Submit_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)
test.Text &= "OnCommand" & "<br/>"
End Sub

Protected Sub Reload_OnComman d(ByVal sender As Object, ByVal Args
As CommandEventArg s)

Response.Redire ct(HttpContext. Current.Request .ServerVariable s("SCRIPT_NAME" ))
End Sub

Protected Sub Page_LoadComple te(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.PreLoad
test.Text &= "LoadComple te" & "<br/>"
End Sub

Protected Sub Page_PreRender( ByVal sender As Object, ByVal e As
System.EventArg s) 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"
UseSubmitBehavi or="true" EnableViewState ="true"
OnCommand="Relo ad_OnCommand"
CommandArgument =''
CommandName="re load" /><br />
<asp:Button ID="Submit" runat="server" Text="Submit"
runat="server"
UseSubmitBehavi or="true" EnableViewState ="true"
OnCommand="Subm it_OnCommand"
CommandArgument =''
CommandName="po st" /><br />
<asp:Label ID="test" runat="server"> </asp:Label>
</form>
</body>
</HTML>
Dec 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2439
by: Christian H | last post by:
Hi! I've created a custom control (myDrawControl) that deals with drawing. This control is then added to a form( myMainForm) Now, whenever something is dragged and dropped onto myDrawControl , I want to update a variable in myMainForm that keeps track of the objects that have been added.(ArrayList objectsAdded) Now I'm a little confused... How can I do this, when the method that deals
2
2226
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I am running into is that I cannot get the click event of this object handled. I have tried wiring the event with "AddHandler" among other things and that seems not to work neither.
3
2303
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace WebApplication1 { using System;
7
4975
by: Frédéric Mayot | last post by:
Hi I'm trying to define a skin for a custom control. I can't see how to do it... My custom control inherits from a TextBox but it doesn't recognize the skinID defined for asp:TextBox. Any idea ? Thanks, Fred
7
3017
by: Shimon Sim | last post by:
I have a custom composite control I have following property
10
3280
by: Jon | last post by:
I'm investiging multi-threaded GUI applications; specifically the technique used to ensure that controls are only modified under the correct thread. The standard technique is to use if(InvokeRequired == true) ... BeginInvoke(...) ... I have some code that ensures that an event fired from a worker (non-GUI) thread will use the appropriate BeginInvoke call for synchronisation. By offloading the synchronisation onto the worker thread the...
19
4919
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom controls which utilize custom classes to wrap built-in controls, and add additional functionality....
4
2770
by: Dan Soendergaard | last post by:
Hello fellow developers, I've created a control which derives from the .NET TextBox. I then wanted to add two events to the new control, so I added the following to the control code: public event EventHandler InvalidValueMatched; public event EventHandler ValidValueMatched; But when one of the events is raised I get this exception:
4
2044
by: Joergen Bech | last post by:
I sometimes use delegates for broadcasting "StateChanged" events, i.e. if I have multiple forms and/or controls that need updating at the same time as the result of a change in a global/common object, I keep local references to this object in each UI object, e.g. Private WithEvents _tools As RepeatTools and catch messages in an event handler like this:
0
9420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10205
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2811
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.