我有两个手风琴窗格,如
Accordion a = new Accordion();
Accordion b = new Accordion();
在我的asp.net Web应用程序中。 我喜欢在Accordion中以编程方式在c#代码中添加Accordion b。 是否可以添加两个这样的手风琴控制? 如果任何人能够提供帮助意味着它对我的项目真的有用。 非常感谢....
答案 0 :(得分:0)
尝试一些喜欢的东西(未经测试 - 只是出于我的想法):
AccordionPane pane = new AccordionPane();
a.Panes.Add(pane);
pane.ContentContainer.Controls.Add(b)
答案 1 :(得分:0)
来自this网站,您可以尝试以下几点:
<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>
答案 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>