Clean up event handlers?

  • Thread starter Thread starter Norton
  • Start date Start date
N

Norton

If I add an event handler in my asp.net page in Page_Load like this:

top_header h = ((top_header)FindControl("Header1"));
h.myEventHandler += new header.GiveMeNewDataEventHandler(this.OnGetNewData);

is there a reason to ever clean up after myself on this? For example, this
code will be called on each page load. Or maybe I should put the handler in
another function?

I have a user control that contains the actual event and I have dropped the
user control onto a page. The code above is from the main page.

Thanks.

Norton
 
Hi,

Norton said:
If I add an event handler in my asp.net page in Page_Load like this:

top_header h = ((top_header)FindControl("Header1"));
h.myEventHandler += new header.GiveMeNewDataEventHandler(this.OnGetNewData);

is there a reason to ever clean up after myself on this?
No really, as soon as the page finish to execute it will be GCed.

You need this if you want to capture that event, it's up to you to decide
when you activate it, maybe you need it only in the first load of the page,
maybe you need it always , or just maybe at a certain moment of the page
processing.


Cheers,
 
Back
Top