adding an accordian pane at runtime

Last post 06-11-2008 8:30 PM by dwhite. 1 replies.

Sort Posts:

  • adding an accordian pane at runtime

    06-11-2008, 4:44 PM
    • Member
      40 point Member
    • MajorFrodo
    • Member since 04-19-2007, 11:06 AM
    • Posts 48

    Hi guys

     

    I have an accordion control and I would like to add another accordion pane at run time. So far I have this:

    Accordion ac = (Accordion)Master.FindControl("Accordion1");
    AccordionPane ap = new AccordionPane();
    ap.Header = "<a href='logout.aspx'>Logout </a>";
    ac.Panes.Add(ap);

    the bolded code will not work since that property expects some Itemplate ... which seems to be somekind of interface.

     

    Does anyone know how to set the value for the header and content properties of the accordian pane class?


    Thanks

     
    Regards

    Gabriel
     

  • Re: adding an accordian pane at runtime

    06-11-2008, 8:30 PM
    Answer
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 9:25 AM
    • Bristol, CT
    • Posts 1,422

    Here's a solution: http://forums.asp.net/p/1253174/2321967.aspx

    The code from that post is as follows:

    1    //Create Templates and give them a literal string that is your content
    2    TemplateBuilder head = new TemplateBuilder();
    3    TemplateBuilder content = new TemplateBuilder();
    4    head.AllowWhitespaceLiterals();
    5    head.AppendLiteralString("&lt;a href=\"\" onclick=\"return false;\" class=\"accordionLink\"&gt;Testin This </a>");
    6    content.AllowWhitespaceLiterals();
    7    content.AppendLiteralString("List Files Here. With Download Button ETC.");
    8   
    9    //Create the Pane and set the head and content to your templatebuilders
    10  AjaxControlToolkit.AccordionPane test = new AjaxControlToolkit.AccordionPane();                   
    11  test.ID = "test";                   
    12  test.Header = head;
    13  test.Content = content;
    14 
    15  //Add Pane To Accordion
    16  Accordion1.Panes.Add(test);

    Visoft, Inc - Home | Blogs

    Latest Blog Post: Silverlight DataBinding Bug
Page 1 of 1 (2 items)