Create Accordion control programmatically

Last post 09-21-2007 2:22 PM by themonko. 3 replies.

Sort Posts:

  • Create Accordion control programmatically

    12-04-2006, 7:14 AM
    • Loading...
    • sailr
    • Joined on 12-04-2006, 12:02 PM
    • Posts 9

    Hi

    This is probably a simple task but I am having no luck with it.

    All I am trying to do is to create an Accordion control with in a ASP panel programmatically on the click of a button.

    Can anyone tell me what is wron here? 

    Example code here:

    protected void Button4_Click(object sender, EventArgs e)
        {
            AjaxControlToolkit.Accordion ac = new AjaxControlToolkit.Accordion();
            ac.HeaderCssClass = "accordionHeader";
            ac.ContentCssClass = "accordionContent";
            ac.FramesPerSecond = 40;
            ac.TransitionDuration = 250;
            ac.ID = "Acc" + acid.ToString();
            acid++;
          
            Literal lt = new Literal();
            lt.Text = "New Added Panedl";
            Label lb = new Label();
            lb.Text = "New Content added";

            AjaxControlToolkit.AccordionPane p = new AjaxControlToolkit.AccordionPane();
            p.HeaderContainer.Controls.Add(lt);
            p.ContentContainer.Controls.Add(lb);
            ac.Panes.Add(p);


            Panel2.Controls.Add(ac);
          
        }
     Thanks

    Sailr 

    Sailr
    http://www.nebtech.net
  • Re: Create Accordion control programmatically

    12-07-2006, 4:10 PM
    Answer
    • Loading...
    • brendalisa
    • Joined on 11-29-2006, 4:02 PM
    • Posts 40

    Maybe have something like this on your .aspx page: 

    <AjaxControlToolkit:Accordion ID="Accordion1" runat="server" TransitionDuration="1" FramesPerSecond="1"

    SelectedIndex="0" AutoSize="None" Width="300">

     

    </

    AjaxControlToolkit:Accordion>

     

    Then in the code behind:

    //Header

    Label headerLabel = new Label();

    headerLabel.Text = pair.Value;

    // fullAddress;

    AccordionPane pane = new AccordionPane();

    pane.HeaderContainer.Controls.Add(headerLabel);

    pane.HeaderCssClass =

    "propListAccordionHeader";

    pane.ContentCssClass =

    "propListAccordionContent";

    //Content

    LinkButton detailsBtn = new LinkButton();

    detailsBtn.Command +=

    new CommandEventHandler(lnk_CommandDetails);

    detailsBtn.Text =

    "Details";

    detailsBtn.CommandArgument =

    Convert.ToString(pair.Key); //propertyID

    pane.ContentContainer.Controls.Add(detailsBtn);

    LiteralControl lit = new LiteralControl("<p>");

    pane.ContentContainer.Controls.Add(lit);

    LinkButton pixBtn = new LinkButton();

    pixBtn.Command +=

    new CommandEventHandler(lnk_CommandPictures);

    pixBtn.Text =

    "Pictures";

    pixBtn.CommandArgument =

    Convert.ToString(pair.Key); //propertyID

    pane.ContentContainer.Controls.Add(pixBtn);

    lit =

    new LiteralControl("<p>");

    pane.ContentContainer.Controls.Add(lit);

     

    Or something like that...

    Brenda
  • Re: Create Accordion control programmatically

    07-06-2007, 10:00 AM
    • Loading...
    • VinBrown
    • Joined on 07-06-2007, 1:57 PM
    • Posts 23

    Thank you so much for this solution. I was looking everywhere for a solution to the original poster's problem with no luck, until I stumbled across this. My team and I are now singing your praises!

  • Re: Create Accordion control programmatically

    09-21-2007, 2:22 PM
    • Loading...
    • themonko
    • Joined on 09-21-2007, 2:21 PM
    • Posts 1

    Are any "using" statements needed to use this?  It seems AccordionPane is not recognized.

    Thanks! 

     

    UPDATE:  I think I figured it out.  In the code it should be AjaxControlToolKit.AccordionPane.  Is there a way to include the AjaxControlToolKit with a using statement? 

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter