Skip navigation.

ColoRotate Is Cooler Than KulerAll recent postsDear Art Director...

Two Components with The Same Id AJAX Error

While debugging a script control written with ASP.NET AJAX, we came across this weird exception:

Sys.InvalidOperationException: Two components with the same id '[....]' can't be added to the application.

The control looked kosher in every respect. Yet we couldn’t understand why the client-side “runtime” was trying to create another instance of this script control on every AJAX call. It’s as if it wouldn’t let go of an old instance before attempting to create a new one.

Looking for a solution in Google, it became obvious there were many various causes of the above exception, but one stood out: make sure you call the base dispose in your script control.

I looked at my dispose method:

dispose : function () {
  delete this._remove$delegate;
  delete this._add$delegate;
}

Duh! It should’ve looked as follows:

dispose : function () {
   delete this._remove$delegate;
   delete this._add$delegate;
   [my namespace].[my class].callBaseMethod (this, "dispose");
}

A self-inflicted painful lesson. I hope it saves somebody debugging time.

Comments

Comment permalink 1 Abdul Qadir Khan |
Dear

can yuou provide more details, I m new in DotNet

i m using partial classes (VCB.net 3.5), m i to ovveride the page dispose method ?

i have only disposed method???

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):