changing the order event handlers

  • Thread starter Thread starter Andy Fish
  • Start date Start date
A

Andy Fish

Hi,

My specific scenario is with the page load event in an asp.net page but I
presume the question applies to everything using the event mechanism.

The documentation says that there is an ordered list of handlers for any
given event. I want to insert an event handler at the beginning so it gets
called first, but I can't find a way to do this. For example the normal code
is:

this.Load += new System.EventHandler(this.Page_Load);

Now, I have a class hierarchy and I want the superclass page_load to get
called first, but it gets installed later. In the documentation for "+=" it
says that a+=b is the same as a=a+b except that a is only evaluated once, so
I thought this would work:

this.Load = new System.EventHandler(this.Page_Load) + this.Load;

but I get a syntax error.

Any ideas? It seems pretty silly having an ordered list if there is no way
to manipulate the order.

Andy
 
Hi Andy,

I think changing the order of page events is not possible. Rather u could
call the pageload method of the base class from your subclass by calling
base.pageload() method in the first line of the load method of the base class.
 
Back
Top