Monday, April 23

Create Dynamic Accordion With multiple AccordionPane

Here i am Going to Post My Both Source And Page Behind code

My Source Code:-



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
   <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Panel ID="Panel1" runat="server">

        </asp:Panel>
    </div>
    </form> 
</body>
</html>

My Page Behind Code:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Accordion acrd = new Accordion();
        acrd.ID = "Accordion1";
        acrd.BorderStyle = BorderStyle.Solid;
        acrd.BorderColor = System.Drawing.Color.Black;
        acrd.BackColor = System.Drawing.Color.Gray;
        //This is for first Accordian Pane
        AccordionPane acpane = new AccordionPane();
        acpane.ID = "Shibashish";

       
        Label lbl = new Label();
        lbl.Text = "jay(Click Me To Open)   Accordionpane1";
        acpane.HeaderContainer.Controls.Add(lbl);
        acpane.HeaderContainer.BorderStyle = BorderStyle.Double;
        acpane.HeaderContainer.BorderColor=System.Drawing.Color.Red;
        acpane.HeaderContainer.BackColor = System.Drawing.Color.Green;
          TextBox txt = new TextBox();
        txt.Text = "om namah shivaya";
        acpane.ContentContainer.Controls.Add(txt);
        acpane.ContentContainer.Controls.Add(new LiteralControl("</br>This is my dynamic Accordian application"));
        acrd.Panes.Add(acpane);

       
        //This is for Second Accordian Pane
        AccordionPane acpane1 =  new AccordionPane();
        acpane1.ID = "Mohanty";
        acpane1.HeaderContainer.Controls.Add(new LiteralControl("Jagdish(Click Me To Open)    Accordionpane2"));
        acpane1.HeaderContainer.BorderStyle = BorderStyle.Double;
        acpane1.HeaderContainer.BorderColor = System.Drawing.Color.Blue;
        acpane1.HeaderContainer.BackColor = System.Drawing.Color.YellowGreen;
        TextBox txt1 = new TextBox();
        txt1.Text = "om namah ganesh";

        //Added the contents object in AccordionPane
        acpane1.ContentContainer.Controls.Add(txt1);

        //Added the AccordionPane object in Accordion
        acrd.Panes.Add(acpane1);
        //Added the Accordion object in Panel
        Panel1.Controls.Add(acrd);

       
    }
}



Thanks Shibashish Mohanty

No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

.

ShibashishMnty
shibashish mohanty