Geeks With Blogs
kazim mehdi

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.
Posted on Wednesday, January 13, 2010 3:29 AM asp.net , ajax | Back to top


Comments on this post: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)

# re: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)
Requesting Gravatar...
Could you send me the fix? I am not able to get to the blog link.
Thank you!! :)
Left by Wendi on Apr 08, 2010 3:24 PM

# re: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)
Requesting Gravatar...
Could you send me the fix? I am not able to get to the blog link.
Thank you!! :)
Left by mukesh on Jun 19, 2010 9:05 AM

# re: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)
Requesting Gravatar...
Could you send me the fix? I am not able to get to the blog link.
Thank you!!
Left by uday on Nov 09, 2010 6:04 AM

# re: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)
Requesting Gravatar...
Hello, I'm from Brazil and I am having this same problem, but I could not understand the solution mentioned above, you could send me the fix?

Thank you very much
Left by Edson Domenech on Aug 25, 2011 3:16 PM

# re: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method (Solution)
Requesting Gravatar...
Hello All,

Can you please send me this fix?

I am not able to get this scripmanager code

Thank you very much
Left by Hemant on Nov 02, 2011 11:54 AM

Your comment:
 (will show your gravatar)


Copyright © kazim sardar mehdi | Powered by: GeeksWithBlogs.net