Page 1 of 1

Multiple controls with same ID error

Posted: Sat Apr 18, 2009 3:09 pm
by garyb
Hello,

When I'm browsing my catalog it gives me the following error:

Multiple controls with the same ID’C2’ were found. FindControl requires that controls have unique IDs.


I searched the messageboard and found the following so I backed up my database and tired this query:

DELETE FROM ac_CatalogNodes
WHERE (CAST(ac_CatalogNodes.CategoryId as varchar) + '/' +
CAST(ac_CatalogNodes.CatalogNodeId as varchar) + '/' +
CAST(ac_CatalogNodes.CatalogNodeTypeId as varchar))
IN ( SELECT (CAST(CN.CategoryId as varchar) + '/' +
CAST(CN.CatalogNodeId as varchar) + '/' +
CAST(CN.CatalogNodeTypeId as varchar)) as ID
FROM ac_CatalogNodes CN inner join ac_Categories C ON
CN.CatalogNodeId=C.CategoryId
WHERE CN.CatalogNodeTypeId=0 AND CN.CategoryID <> C.ParentID
)

but it said that 0 rows were affected. I haven’t been manually editing my database so I’m not sure what the problem is. BTW the version I am running is:

PLATFORM: ASP.NET
VERSION: 7.0.2
BUILD: 11659

Thanks in advanced for any help.

Re: Multiple controls with same ID error

Posted: Sun Apr 19, 2009 9:03 am
by jmestep
Have you customized the page and what page is it?

Re: Multiple controls with same ID error

Posted: Mon Apr 20, 2009 8:39 pm
by garyb
The page isn't customized. The page is Admin/Catalog/Browse.aspx

Re: Multiple controls with same ID error

Posted: Mon Apr 20, 2009 9:12 pm
by afm
Does the error occur when you cause a postback or a callback (i.e. send something back to the server) or when you first load the page? If the former, when you view the page source with your browser, what 2 controls have the "C2" ID?

Re: Multiple controls with same ID error

Posted: Mon Apr 20, 2009 10:06 pm
by garyb
Only on postback. It doesn't happen with all categories.

Re: Multiple controls with same ID error

Posted: Mon Apr 20, 2009 10:57 pm
by afm
When you view the page source with your browser, which two controls have the "C2" ID?

Re: Multiple controls with same ID error

Posted: Tue Apr 21, 2009 6:13 am
by jmestep
Do any of you categories have apostrophes in the name? Sometimes that causes weird actions.

Re: Multiple controls with same ID error

Posted: Tue Apr 21, 2009 10:46 am
by garyb
The all look like they have unique id's

Code: Select all

<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C1" href="javascript:__doPostBack('ctl00$MainContent$C1','')">PRESCHOOL LEVEL<br /> MONTESSORI MATERIALS & CURRICULUM</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C2" href="javascript:__doPostBack('ctl00$MainContent$C2','')">JUNIOR ELEMENTARY<br /> MONTESSORI MATERIALS & CURRICULUM</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C3" href="javascript:__doPostBack('ctl00$MainContent$C3','')">ADVANCED ELEMENTARY <br />MONTESSORI MATERIALS & CURRICULUM</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C16" href="javascript:__doPostBack('ctl00$MainContent$C16','')">ACP TESTS FOR THE<br /> PRESCHOOL LEVELS</a></div>

<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C17" href="javascript:__doPostBack('ctl00$MainContent$C17','')">ACP TESTS FOR THE <br />JUNIOR ELEMENTARY LEVELS</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C18" href="javascript:__doPostBack('ctl00$MainContent$C18','')">ACP TESTS FOR THE <br />ADVANCED ELEMENTARY LEVELS</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C19" href="javascript:__doPostBack('ctl00$MainContent$C19','')">ALBANESI CURRICULUM PROGRAMS</a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C23" href="javascript:__doPostBack('ctl00$MainContent$C23','')">Special Orders </a></div>
<div class="treeNode"><img src="../../App_Themes/AbleCommerceAdmin/Images/plus.gif" border="0" align="absmiddle" /><a id="ctl00_MainContent_C24" href="javascript:__doPostBack('ctl00$MainContent$C24','')">KB</a></div>
</div>

Also no commas

Re: Multiple controls with same ID error

Posted: Tue Apr 21, 2009 11:00 am
by afm
I agree...no duplicates visible. Any chance there is an ID with "C2" in a part of the page you did not show us?

Does it happen with all browsers? For example, if you normally use Internet Explorer, does it happen with FireFox?

Re: Multiple controls with same ID error

Posted: Tue Apr 21, 2009 11:25 am
by garyb
No other parts that I can see, but I think some code is coming with the post back, you know when it expands the category tree.

Just checked IE, same errors on the same categories.

How are the ID's assigned?

Re: Multiple controls with same ID error

Posted: Tue Apr 21, 2009 2:03 pm
by afm
The ID's are created in layers: first AbleCommerce assigns the "C2" part and then ASP.NET prepends the "MainContent_" parts. When your browser causes a postback, it goes in reverse: ASP.NET uses the "MainContent_" part to figure out which panel the control belongs to and then uses the "C2" part to figure out which control. The error message means that ASP.NET see 2 controls named "C2" in the same panel.

Obviously it does not normally occur and I don't know what would cause it. If it were my site, I think I might start by making sure all critical Windows updates are installed and then use a tool like Fiddler to look at the postbacks.