Dealing with "Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method."
August 13, 2007
In the ListSearch extender I recently had a bug where you got an exception when leaving a page that had a ListBox on it, where the ListBox was the target of both a CascadingDropDown extender and a ListSearch extender.
The reason was pretty dumb– I was calling $clearHandlers(listBox) in the dispose method on the ListSearch Extender, and this was removing the handlers that the CascadingDropDown had set up. So when the CascadingDropDown’s dispose method tried to clean up its event subscriptions, the ASP.NET AJAX runtime complained that it was not subscribed.
The solution was replace calls to $addHandlers and $clearHandlers with individual calls to $addHandler and $removeHandler for each individual event in the ListSearch’s initialize and dispose methods.
Unfortunately after implementing this solution I still got the same error … after a lot of head-scratching, it turned out to be a simple typo. I was calling $addHandler with ‘keydown’ as the event name, and calling $removeHandler with ‘keyDown’ as the event name.
A couple of things for you to check if you get the same error.
September 3, 2007 at 12:12 pm
Thanks for the info, faced the same problem with an extender of my own.
It’s a pity because clearHandlers would be very nice to use :-(
March 20, 2008 at 12:17 pm
hi,
I recently started using the AJAX toolkit. ListSearchExtender is 1 of the coolest in the kit. I have question, can we make some changes so that hidden div is shown and the user can actually type in the div instead of the listbox. i know that would b difficult thing for me,the way i see the code i hav lot to learn. is it possible by u to do that…
thanks much,