Home All Groups Group Topic Archive Search About
Author
15 Apr 2005 1:36 PM
Tim
If you instantiate a web control programmatically in Form_Load and then add
a click event handler to it using AddHandler MyControl.Click AddressOf
MyEventHandler, is it necessary to call RemoveHandler MyControl.Click
AddressOf MyEventHandler in the Page_Unload event? Does not removing
handlers have any side effects?
Thanks
Tim

Author
15 Apr 2005 3:13 PM
Brock Allen
In ASP.NET, no, it's not necessary. You typically only do this if your ccode
that was receiving the event is still running and you no longer want to receive
the event. Since ASP.NET creates a page for every request, the page and all
the child contorls are thrown away so no need to stop receiving the event
as the source of the event is gone itself, so to speak.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> If you instantiate a web control programmatically in Form_Load and
> then add
> a click event handler to it using AddHandler MyControl.Click AddressOf
> MyEventHandler, is it necessary to call RemoveHandler MyControl.Click
> AddressOf MyEventHandler in the Page_Unload event? Does not removing
> handlers have any side effects?
> Thanks
> Tim
Author
15 Apr 2005 7:46 PM
Steve C. Orr [MVP, MCSD]
No, that's not necessary in ASP.NET, and it has no real effect.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Show quoteHide quote
"Tim" <t**@nowhere.org> wrote in message
news:eo2TdAcQFHA.2252@TK2MSFTNGP15.phx.gbl...
> If you instantiate a web control programmatically in Form_Load and then
> add
> a click event handler to it using AddHandler MyControl.Click AddressOf
> MyEventHandler, is it necessary to call RemoveHandler MyControl.Click
> AddressOf MyEventHandler in the Page_Unload event? Does not removing
> handlers have any side effects?
> Thanks
> Tim
>
>