社区
C#
帖子详情
foreach Controls的问题
littlefairy
2006-12-28 08:32:33
foreach (object Kid in this.InsetPanel.Controls)
我的InsetPanel包含很多asp:table,asp:table里面又包含控件,现在我这样foreach却一个控件都取不到,是不是和后台table有关?因为之前做的是可以的
...全文
151
8
打赏
收藏
foreach Controls的问题
foreach (object Kid in this.InsetPanel.Controls) 我的InsetPanel包含很多asp:table,asp:table里面又包含控件,现在我这样foreach却一个控件都取不到,是不是和后台table有关?因为之前做的是可以的
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
littlefairy
2006-12-28
打赏
举报
回复
搞定!递归就可以了,呵呵
littlefairy
2006-12-28
打赏
举报
回复
还是取不到,取到的都是TABLEROW TABLECELL
maliang00111
2006-12-28
打赏
举报
回复
又看到传说中的红钻了哈哈~~
littlefairy
2006-12-28
打赏
举报
回复
哇,楼主好幸福,有钻石帮忙!
呵呵,我也是这么认为的,正在测试
marysxj
2006-12-28
打赏
举报
回复
哇,楼主好幸福,有钻石帮忙!
marysxj
2006-12-28
打赏
举报
回复
你把这句foreach (object Kid in this.InsetPanel.Controls)改为foreach (Control
Kid in this.InsetPanel.Controls)
孟子E章
2006-12-28
打赏
举报
回复
Control _obj = null;
string ControlID = "";
void GetChildControl(Control ParentControl)
{
if (ParentControl.HasControls())
{
foreach (Control ctl in ParentControl.Controls)
{
//处理ctl
GetChildControl(ctl);
}
}
}
ustbwuyi
2006-12-28
打赏
举报
回复
应该没有关系吧,你把table都去掉然后试试看可以取到不,可以取就是table的关系咯
另外你可以跟踪一下看看,看看this.InsetPanel.Controls里面包含了一些什么元素..
循环动态判断checkbox是否被选中
循环动态判断checkbox是否被选中
foreach
(Control c in Panel1.
Controls
)
ASP.NET(C#)中遍历所有控件
代码如下:for (int i = 0; i < this.
Controls
.Count; i++) {
foreach
(System.Web.UI.Control control in this.
Controls
[i].
Controls
) { if (control is TextBox) (control as TextBox).Text = “”; } }
foreach
(Control cl in this.Page.FindControl(“Form1”).
Controls
) { if (cl.GetType().ToString() == “System.Web.UI.WebC
asp.net下遍历页面中所有的指定控件的代码
1.遍历页面中所有的TextBox,并将值设置成String.Empty 代码如下: for (int j = 0; j < this.
Controls
.Count; j++) {
foreach
(object o in Page.
Controls
[j].
Controls
) { if (o is TextBox) { TextBox txt = (System.Web.UI.Web
Controls
.TextBox)o; txt.Text = String.Empty; } } } 2.递归遍历 代码如下: private void FindAllTextBoxByPageControl
asp.net 初始化文本框的小例子
代码如下:private void ClearAllText(System.Web.UI.Control contrl) { int ctl_count=contrl.
Controls
.Count; for (int i=0;i<ctl_count;i ) {
foreach
(Control ctl in contrl.
Controls
[i].
Controls
) { if (ctl.Has
Controls
()) { ClearAllText(ctl.Parent); } else { if (ctl
递归禁用子控件
公共无效
ControlS
tatus(Control control,bool isDisable){
foreach
(control.
Controls
中的Control c)如果(c.Has
Controls
())
ControlS
tatus(c,isDisable); 否则{WebControl wc = c作为WebControl; 如果(wc!= null)...
C#
110,565
社区成员
642,567
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章