1. 建立 Web表單:Accordion.aspx
2. 添加一個 ScriptManager 控制項
3. 添加一個 Accordion 控制項 (注意:拖動 Accordion 控制項到表單中時,表單是什麼也顯示的,只在源碼裡增加代碼)Code
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<cc1:Accordion ID="Accordion1" runat="server">
</cc1:Accordion>
<br />
<br />
</div>
</form>
</body>
4. 在 <cc1:Accordion ID="Accordion1" runat="server"></cc1:Accordion> 中添加 <Panes></Panes>
5. 在 <Panes></Panes> 中拖幾個AccordionPane進去(你需要幾層就拖幾個)
Code
<cc1:Accordion ID="Accordion1" runat="server">
<Panes>
<cc1:AccordionPane ID="AccordionPane1" runat="server">
</cc1:AccordionPane>
<cc1:AccordionPane ID="AccordionPane2" runat="server">
</cc1:AccordionPane>
<cc1:AccordionPane ID="AccordionPane3" runat="server">
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
6. 給 AccordionPanel 添加代碼:Code
<cc1:Accordion ID="Accordion1" runat="server">
<Panes>
<cc1:AccordionPane ID="AccordionPane1" runat="server">
<Header>這裡是標題1</Header>
<Content>這裡是標題1 的內容</Content>
</cc1:AccordionPane>
<cc1:AccordionPane ID="AccordionPane2" runat="server">
<Header>這裡是標題2</Header>
<Content>
這裡是標題2 的內容
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane ID="AccordionPane3" runat="server">
<Header>這裡是標題3 </Header>
<Content>這裡是標題3 的內容</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
7. OK,運行,已經可以用了,只是沒有邊框和顔色。
8. 現在要做的就是給標題加上邊框的顔色。
① 開啟 Accordion1 屬性面板,設定大小, Height(300px) , Width(200px)
② 設定標題樣式, HeaderCssClass(accordionHeader)
③ 設定內容樣式, ContentCssClass(accordionContant)
8. 建立樣式。Code
<style type="text/css">
.accordionHeader
{
color: #FFFF00;
background-color: #3399FF;
border: 1px solid #FF6600;
padding: 1px;
margin: 1px;
cursor: pointer;
}
.accordionContent
{
background-color: #FF9933;
padding: 1px;
margin: 1px;
}
</style>
9. OK,試試看吧 !!!