ASP.NET Ajax exception – Two components with the same id can’t be added to the applicati

來源:互聯網
上載者:User

There's a couple of exceptions to look out for when you start developing custom ASP.NET Ajax client controls.  They are:

Microsoft JScript runtime error: Sys.InvalidOperationException: Two components with the same id 'ctl00_MainContentPlaceHolder__eventsRepeater_ctl01_ke1' can't be added to the application.

and...

Microsoft JScript runtime error: Sys.InvalidOperationException: A control is already associated with the element.

These errors can be caused when you have a custom control/component which gets added and then re-added at some later point in time - such as when you have a partial page render.  This is being caused because the Sys.Control or Sys.Component gets registered with the Sys.Application when you call the initialize method of your component like so:

MarkItUp.Web.MyCustomControl.callBaseMethod(this, 'initialize') ;

Under the hood, the Sys.Application keeps a list of all the components that are registered with it - that's how $find works.  So when you call 'initialize', Sys.Application looks at the list of components that it currently knows about and if yours already exists then you will likely see one of the errors listed above.

The trick is to make sure that you call dispose on your control's base when you are finished:

dispose : function() {
    $clearHandlers(this.get_element()) ;
    // any other cleanup work

MarkItUp.Web.MyCustomControl.callBaseMethod(this, 'dispose') ;
}

FROM:

http://showusyourcode.spaces.live.com/Blog/cns!15630F96CB7D86C1!582.entry

http://forums.asp.net/p/1066748/1548516.aspx

http://www.velocityreviews.com/forums/t518005-two-components-with-the-same-id-cant-be-added-to-the-application.html

http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_23735231.html

http://www.eggheadcafe.com/software/aspnet/30226324/two-components-with-the-s.aspx

http://bytes.com/groups/net-asp/669319-two-components-same-id-cant-added-application

http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=8904

http://www.telerik.com/community/forums/aspnet/ajax/sys-invalidoperationexception-two-components.aspx

http://www.nikhilk.net/Entry.aspx?id=152

http://forums.asp.net/p/1342154/2719761.aspx#2719761

http://stackoverflow.com/questions/397051/ajax-toolkit-reorderlist-two-components-with-the-same-id-componentid-cant-be-a

http://66.129.67.4/t/1094818.aspx

http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.aspnet/2007-06/msg03056.html

http://dariosantarelli.wordpress.com/2007/06/13/ajaxcontroltoolkit-v1010606-strange-behaviour-of-the-modalpopupextender-control-with-dropshadow/

http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=10945

Calendar Extender generates message "Sys.InvalidOperationException: Two components with the same id '{ExtenderId}' can't be added to the application error." when the container update panel is refreshed

http://forums.asp.net/t/1127745.aspx 

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

http://forums.asp.net/p/1342703/2721397.aspx

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.