abend
abend

Reputation: 483

page/control lifecycle

I have usercontrol x in a page, within usercontol x is usercontrol z. I need to do something to usercontrol z after an event fires in usercontrol x. I understand this is very generic, but it just lays out a simple premise for my issue.

Is there a simple way to get a list of all events that fire in the page lifecycle whether I am subscribed to them or not to find out what events fire between Event A on the page and Event B on control z? I would think that there would be something like this when page tracing is turned on, but I don't see any events listed. I imagine that it would be something that the pipeline could generate, maybe I could use reflection to get a list?

I found this topic hard to search against in general, maybe I am using bad keywords... I did find an old project on codeproject.com, but I was hoping that there would be something more elegant available by now.

*To clarify, I'm looking to generate a list after a postback of every potential event (subscribed or not), in firing order from init to unload, of all controls on a page.

THIS POST: Tracing all events in VB.NET gets me a little bit closer, however these are lists on a per control basis, not in chronological order.

Upvotes: 1

Views: 389

Answers (3)

Chris Shouts
Chris Shouts

Reputation: 5427

The ASP.NET Page Life Cycle Overview on MSDN lists all of the events fired by a Page from PreInit to Unload. Most of these events fire on any class that inherits from System.Web.UI.Control as well.


Update

Now that I understand your intention better, one possible solution would be to loop through the events of every control and assign an event handler that logs the calling of the event. There is at least one way to retrieve all of the event handlers assigned to an event, and it shouldn't be too difficult to adapt that code to assign an event handler instead.

Upvotes: 0

Priyank
Priyank

Reputation: 10623

Enable trace with <%@ Page Trace="true" %> in page attribute. that should display life cycle events in sequence.

Upvotes: 1

BrandonZeider
BrandonZeider

Reputation: 8152

Well if you're just looking to see what the events are in general, and in what order they fire, check out this article. As far as getting them...well, that depends on what you mean. It could be as simple as getting them through reflection:

EventInfo[] events = this.GetType().GetEvents();

Upvotes: 0

Related Questions