0
特別是一個文本框已被跳過。該ID爲「q3TXT」的文本框位於隱藏在PageLoad方法中的面板內。this.Controls不包含所有控件
然而,它在收集控件的函數之前變得可見。
收集其他每個文本框。
我已經嘗試過使用IEnumberable的文本框集合,但沒有工作。
如何讓文本框出現在控件列表中?
這裏是HTML:
<p id="question3Text" runat="server" class="question"></p>
<asp:RadioButtonList runat="server" ID="q3_RBList" AutoPostBack="true" OnSelectedIndexChanged="q3_RBList_SelectedIndexChanged">
</asp:RadioButtonList>
<asp:Panel runat="server" ID="q3Panel">
<p>If no, when did data collection stop?</p>
<asp:TextBox runat="server" ID="q3TXT"></asp:TextBox>
</asp:Panel><br /><br />
和C#代碼的一部分:
foreach (var item in this.Controls.OfType<TextBox>())
{
//some code
}
非常感謝! – 2013-05-14 09:17:39
不客氣;) – Mehran 2013-05-14 09:17:59