尤其是一个文本框已被跳过。该ID为 q3TXT的文本框位于面板内,该面板在PageLoad方法中隐藏。
One text box in particular has been skipped. That textbox with ID "q3TXT" is inside a panel which is hidden at the PageLoad method.
但是在收集控件的函数之前它是可见的。
Yet it becomes visible before the function that collects controls.
会收集所有其他文本框。
Every other textbox is collected.
我尝试使用IEnumberable文本框集合,但无法正常工作。
I've tried with IEnumberable collection of textboxes, which didn't work.
如何使文本框出现在控件列表中?
How can I make the textbox appear in the controls list?
此处是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#代码的一部分:
And a part of c# code:
foreach (var item in this.Controls.OfType<TextBox>()) { //some code }推荐答案
特定的 textBox 是您特定的 panel 的一部分,因此您应该在 panel.Controls 而不是 this.Controls
that specific textBox is a part of your specific panel so you should look for it inside of panel.Controls instead of this.Controls
更多推荐
this.Controls不包含所有控件
发布评论