【问题标题】:this.Controls doesn't contain all controlsthis.Controls 不包含所有控件
【发布时间】:2013-05-08 11:23:47
【问题描述】:

特别是一个文本框已被跳过。 ID 为“q3TXT”的文本框位于一个面板中,该面板隐藏在 PageLoad 方法中。

然而它在收集控件的函数之前变得可见。

收集所有其他文本框。

我尝试过使用 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
}

【问题讨论】:

    标签: c# textbox controls dotnetnuke


    【解决方案1】:

    那个特定的textBox 是你的特定panel 的一部分,所以你应该在panel.Controls 而不是this.Controls 中寻找它

    【讨论】:

      猜你喜欢
      • 2012-09-10
      • 1970-01-01
      • 2021-04-24
      • 2012-02-17
      • 2019-10-01
      • 2010-12-14
      • 2011-08-29
      • 2012-12-23
      • 2020-06-20
      相关资源
      最近更新 更多