ASP. NET Ajax exception-two components with the same ID can't be added to the applicati

Source: Internet
Author: 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.