this.Controls不包含所有控件

编程入门 行业动态 更新时间:2024-10-19 20:31:44
本文介绍了this.Controls不包含所有控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尤其是一个文本框已被跳过。该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不包含所有控件

本文发布于:2023-11-06 13:51:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563874.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   不包含   Controls

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!