Accordionpane计算内部和存储在数组中的分区数

时间:2013-01-10 08:49:07

标签: asp.net vb.net master-pages accordionpane

 <asp:accordionpane id="colors">

   <header> colors</header>

   <content>
    <div> blue </div>
    <div> red  </div>
    <div> gray </div>
   </content>

 </accordionpane>

有没有找到div的方法并遍历循环
并在数组中存储名称,如字符串colors{} = accordionpane.div("blue"), accordionpane.div("red"), accordionpane.div("gray")

或有没有办法找到一个手风琴有div还是没有

1 个答案:

答案 0 :(得分:1)

如果要在服务器端访问它,请将其设为runat=server(甚至更好 - Panel)。否则,您无法遍历colors.Controls,因为它是空的。

<asp:accordionpane id="colors">

   <header> colors</header>

   <content>
    <asp:Panel id="pnlBlue" runat="server"> blue </asp:Panel>
    <asp:Panel id="pnlRed" runat="server"> red  </asp:Panel>
    <asp:Panel id="pnlGray" runat="server"> gray </asp:Panel>
   </content>

</accordionpane>

现在这个Linq查询有效:

Dim panelText = From p In colors.Controls.OfType(Of Panel)()
    Select p.Controls.OfType(Of LiteralControl)().First().Text.Trim()
Dim count As Int32 = panelText.Count()
Dim allColors = String.Join(",", panelText)