AJAX擴充控制項Accordion的使用方法總結

來源:互聯網
上載者:User

如所示為Accordion控制項:

 感覺不錯的樣式

  <style type="text/css">
.headerBg{cursor:hand;text-align:center;width:180px;height:21px;background-image:url(images/ajaxmenubg1.gif);FONT-SIZE: 12px;line-height:21px;}          
.contentBg{width:180px;text-align:left;BACKGROUND-COLOR: #D1ECC8; FONT-SIZE: 12px; Font-color: #669900; FONT-FAMILY: "宋體"}
</style>
</head>

一、靜態載入:

頁面代碼如下:

  <form id="form1" runat="server"><br /> <div><br /> <asp:ScriptManager ID="ScriptManager1" runat="server"><br /> </asp:ScriptManager><br /> <cc1:Accordion ID="Accordion1" runat="server" Height="329px" Width="198px"<br /> HeaderCssClass ="accordionHeader"<br /> ContentCssClass ="accordionContent"<br /> FadeTransitions ="true"<br /> TransitionDuration ="300"<br /> FramesPerSecond ="20"<br /> RequireOpenedPane ="false"<br /> SelectedIndex ="-1"<br /> ><br /> <Panes><br /> <cc1:AccordionPane runat ="server"><br /> <Header>張佳佳</Header><br />     <Content>態度決定一切</Content><br /> </cc1:AccordionPane><br /> <cc1:AccordionPane ID="AccordionPane1" runat ="server"><br /> <Header>*佳佳*</Header><br />     <Content>太陽像往常一樣升了起來</Content><br /> </cc1:AccordionPane><br /> <cc1:AccordionPane ID="AccordionPane2" runat ="server"><br /> <Header>i++</Header><br />     <Content>做好自己該做的!</Content><br /> </cc1:AccordionPane><br /> <cc1:AccordionPane ID="AccordionPane3" runat ="server"><br /> <Header>傻妞</Header><br />     <Content>如果有一天,我們都不會說話了,希望我們依然能住在愛的天堂裡</Content><br /> </cc1:AccordionPane><br /> </Panes><br /> </cc1:Accordion><br /> </div></p><p> </form>

 

動態載入(從資料庫中查詢資料載入)

頁面代碼:

<form id="form1" runat="server"><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" /><br /> <div><br /> <cc1:Accordion ID="Accordion1" runat="server" Height="382px" Width="200px" HeaderCssClass="headerBg" ContentCssClass="contentBg"><br /> </cc1:Accordion><br /> </div><br /> </form>

 

後台代碼:

protected void Page_Load(object sender, EventArgs e)<br /> {<br /> if (!Page.IsPostBack)<br /> {<br /> Display(); //顯示學生資訊<br /> }<br /> }</p><p> private void Display()<br /> {<br /> //得到所有學生的資訊<br /> List<Student> list = GetAllStudent();</p><p> //迴圈將學生ID添加到Accordion控制項的標題中<br /> foreach (Student item in list)<br /> {<br /> AccordionPane ap = new AccordionPane(); //執行個體化一個AccordionPane 控制項<br /> Label lblStudentMenu = new Label(); //執行個體化一個標籤控制項用來顯示分類名<br /> lblStudentMenu.Text = item.Id.ToString();//指定標籤的Text屬性為分類名<br /> ap.HeaderContainer.Controls.Add(lblStudentMenu); //將標籤控制項添加到AccordionPane標題部分</p><p> HyperLink hlinkStudentMenu = new HyperLink();<br /> hlinkStudentMenu.Text = "   " +item.Name + "<br>";//指定HyperLink的Text屬性為學生姓名<br /> hlinkStudentMenu.NavigateUrl = "#"; //指定串連屬性<br /> ap.ContentContainer.Controls.Add(hlinkStudentMenu);//將串連控制項添加到AccordionPane內容部分</p><p> Accordion1.Panes.Add(ap);//將AccordionPane追加到Accordion的Panes集合中<br /> }</p><p> }

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.