Sunday, October 20, 2013

Multiple controls with the same ID '_header' were found. FindControl requires....(Asp.net Ajax)

Good day!

After integrating ajax accordion pane controls in my asp.net app,
An exception pops up as stated by the title of the post.

The culprit was that I initialized two AccordionPane objects w/o
specifying the ID's of each object.

The solution is to include ID's in each control.See example below:
Code:
AccordionPane ap1 = new AccordionPane();  
 ap1.ID = "ap1";  
 ap1.HeaderContainer.Controls.Add(new LiteralControl("Product Code"));  
 ap1.ContentContainer.Controls.Add(new LiteralControl(datarow["ID"].ToString();));  

 AccordionPane ap2 = new AccordionPane();  
 ap2.ID = "ap2";  
 ap2.HeaderContainer.Controls.Add(new LiteralControl("Product Name"));  
 ap2.ContentContainer.Controls.Add(new LiteralControl(datarow["Prod_Name"].ToString();));
Greg

0 comments:

Post a Comment