I have a Model popup from ajax control toolkit in my page.that point to a asp:panel that will going to show a close button in the top left corner. When using with update panel and lots of ajax stuff ended up getting the following javascript error in IE only , it worked perfectly in firefox
Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method
i searched alot on the internet for the solution, solution was there that suggest just move the button outside the update panel
solution to the above stated scenario
http://forums.asp.net/t/1055781.aspx
but in my scenario that was not possible as we extened the popup to our needs so searching was continued until i found the following blog post
http://damianblog.com/2007/08/13/not-added-through-addhandler/
according to his guidelines i was able to fix the problem by performing the following
1. downloaded the ajax toolkit sourcecode from
http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33804
2. looked into how he solved it there.
3. After initializeBase(this, [element]);
declare and initialize the eventhandler
this._closeNow = null;
4. inside initialize: function()
before i was using $addHandlers
replaced it with seperate $addHandler for each event like the following
this._closeNow = Function.createDelegate(this, this._onCloseNow);
$addHandler(this._closeImage, "click", this._closeNow);
5. inside dispose: function()
before i was using $clearHandlers(this.get_element()); to clear the events
replaced it with seperate $removeHandler for each event thati added in the initialize function like the following
if (this._closeNow)
{
//alert(this._closeNow);
$removeHandler(this._closeImage, "click", this._closeNow);
this._closeNow = null;
}
6. clear the cache of the IE and run it and problem solved.