通过网页上的所有用户控制环路

编程入门 行业动态 更新时间:2024-10-23 21:26:11
本文介绍了通过网页上的所有用户控制环路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

通过存在的页面上,并获得其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);

更多推荐

通过网页上的所有用户控制环路

本文发布于:2023-10-26 12:00:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530074.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环路   网页   用户

发布评论

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

>www.elefans.com

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