第十二篇: Ajax Control Toolkit 控制項包–1. Accordion (多層摺疊效果)

來源:互聯網
上載者:User
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,試試看吧 !!!


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.