About the author

Vijay Kodali
E-mail me Send mail

Site Statistics

Site Meter

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017

Dynamic Accordion control same ID _header error

Multiple controls with the same ID '_header' were found. FindControl requires that controls have unique IDs.

 I got this error, when I tried adding multiple accordion panes to the accordion control in code behind. The problem is with duplicate ID for the panes. Setting unique ID's to dynamic panes will fix the problem.

<cc1:accordion id="Accordion1" runat="Server" selectedindex="0" 
  headercssclass="accordionHeader" contentcssclass="accordionContent" 
  autosize="None" fadetransitions="true" transitionduration="250"
  framespersecond="40" requireopenedpane="false" suppressheaderpostbacks="true">
</cc1:accordion>

In Code behind:

for (int i = 0; i < 3; i++)
{
    AccordionPane pane1 = new AccordionPane();
    //Here i used Guid for uniqueness
    pane1.ID = "AccordionPane" + Guid.NewGuid().ToString();
    Label lbl = new Label();
    lbl.Text = "New pane";
    pane1.Controls.Add(lbl);
    Accordion1.Panes.Add(pane1);
}


Categories: AJAX | Web Development
Posted by vijay on Monday, January 12, 2009 12:39 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading