2012-01-25 19 views
0

私は私のasp.netのWebアプリケーションで別のアコーディオンコントロール内にアコーディオンコントロールをプログラムで追加する方法は?

Accordion a = new Accordion(); 
Accordion b = new Accordion(); 

のような2つのアコーディオン・ペインがあります。 私はAccordion bをプログラムでC#コードの背後に追加したいと思います。 そのような2つのアコーディオンコントロールを追加することはできますか? それを助けることができる人がいれば、それは私のプロジェクトにとって本当に役に立つでしょう。 多くのおかげで....

答えて

0

コードビハインド以外のコードのように見えるようにしたい場合は、コードビハインドのバージョンを参考にしてください。例:

<asp:Accordion ID="AccordionA" runat="server"> 
    <Panes> 
     <asp:AccordionPane ID="AccordionPaneA1" runat="server"> 
      <Header> First Header</Header> 
      <Content>Contents with in the first header </Content> 
     </asp:AccordionPane> 
     <asp:AccordionPane ID="AccordionPaneA2" runat="server"> 
      <Header>Second Header</Header> 
      <Content>Content with in the second Header</Content> 
     </asp:AccordionPane> 
     <asp:AccordionPane ID="AccordionPaneA3" runat="server"> 
      <Header>Third Header With Accordion</Header> 
      <Content> 
       <asp:Accordion ID="AccordionB" runat="server"> 
        <Panes> 
         <asp:AccordionPane ID="AccordionPaneB1" runat="server"> 
          <Header> First Header</Header> 
          <Content>Contents with in the first header </Content> 
         </asp:AccordionPane> 
        </Panes> 
       </asp:AccordionPane> 
      </Content> 
     </asp:AccordionPane> 
    </Panes> 
</asp:Accordion> 
0

は(テストしていない - ちょうど私の頭の外に)のようなsomethin試してみてください:thisサイトのソースさ

AccordionPane pane = new AccordionPane(); 
a.Panes.Add(pane); 

pane.ContentContainer.Controls.Add(b) 
+0

ニースの推測!しかし、それは動作しない、他の提案をお願いしますか? – Kathirvel

0

は、あなたがこれらの線に沿って何かを試すことができます。

<script runat="server"> 
void Page_Load() 
{ 
if (!Page.IsPostBack) 
{ 
AccordionPane ap1 = new AccordionPane(); 
ap1.HeaderContainer.Controls.Add(new LiteralControl("Using Markup")); 
ap1.ContentContainer.Controls.Add(new 
LiteralControl("Adding panes using markup is really simple.")); 
AccordionPane ap2 = new AccordionPane(); 
ap2.HeaderContainer.Controls.Add(new LiteralControl("Using Code")); 
ap2.ContentContainer.Controls.Add(new 
LiteralControl("Adding panes using code is really flexible.")); 
acc1.Panes.Add(ap1); 
acc1.Panes.Add(ap2); 
} 
} 
</script> 
+0

私は2つのアコーディオンではなく、2つのアコーディオンを入れ子にする必要があります。あなたはそれについて提案をお願いしますか? – Kathirvel

関連する問題