This article will explain your when your get the error “Multiple
controls with the same ID '_header' were found. FindControl requires that
controls have unique IDs.” What will be the solution for resolving this error. This
error I face while dynamically adding accordion pan at run time of
ajaccontroltoolkit.
So here is the screen shot of the error.
So here is the cod for which I have faced this error.
AccordionPane ap1 = new
AccordionPane();
ap1.HeaderContainer.Controls.Add(new LiteralControl("Using Markup"));
ap1.ContentContainer.Controls.Add(new LiteralControl("Adding panes using markup is really simple."));
AccordionPane ap2 = new
AccordionPane();
ap2.HeaderContainer.Controls.Add(new LiteralControl("Using Code"));
ap2.ContentContainer.Controls.Add(new LiteralControl("Adding panes using code is really flexible."));
Accordion1.Panes.Add(ap1);
Accordion1.Panes.Add(ap2);
|
Now as per error we are
getting same id for the control which we are adding at run time.
So here is the solution you just needed to add the id for
each and every pan control.
AccordionPane ap1 = new
AccordionPane();
ap1.ID = "ap1";
ap1.HeaderContainer.Controls.Add(new LiteralControl("Using Markup"));
ap1.ContentContainer.Controls.Add(new LiteralControl("Adding panes using markup is really simple."));
AccordionPane ap2 = new
AccordionPane();
ap2.ID = "ap2";
ap2.HeaderContainer.Controls.Add(new LiteralControl("Using Code"));
ap2.ContentContainer.Controls.Add(new LiteralControl("Adding panes using code is really flexible."));
Accordion1.Panes.Add(ap1);
Accordion1.Panes.Add(ap2);
|
Just check the bold part of the code. now run the page you will not get the error.
0 comments:
Please let me know your view