本文介绍了通过网页上的所有用户控制环路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过存在的页面上,并获得其ID的所有用户控件要循环。我该怎么做呢?
Want to loop through all the user controls that exist on the page and get their IDs. How do I do it?
推荐答案要获得每个用户控制,你必须测试控制的类型:
To get each User Control, you'd have to test the Type of the control:
编辑:我修改我的例子去通过递归的所有控件:
I modified my example to go through all controls recursively:
法
public void GetUserControls(ControlCollection controls) { foreach (Control ctl in controls) { if (ctl is UserControl) { // Do whatever. } if (ctl.Controls.Count > 0) GetUserControls(ctl.Controls); } }名为
GetUserControls(Page.Controls);更多推荐
通过网页上的所有用户控制环路
发布评论