简体   繁体   English

如何选择.net / c#中的所有控件,例如jQuery中的$('*')?

[英]how to select all controls in .net/c# like $('*') in jQuery?

只是想知道是否有一种方法可以选择asp.net/c#中的所有控件/项,例如在jQuery中执行的$('*')

看看这个帖子

var allCtrls = GetChildren(Page);

protected IEnumerable<Control> GetChildren(Control parent)
{   
    foreach (Control ctrl in parent.Controls)
    {
        yield return ctrl;
        foreach (Control ctrl2 in GetChildren(ctrl))
            yield return ctrl2;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在.Net C#中获取所有受支持的ldap控件 - How to get all supported ldap controls in .Net C# 列出C#ASP.NET项目中的所有控件 - List All Controls in a C# ASP.NET Project 如何从asp net c#后面的代码清除/重置用户控件中的所有子控件 - How to clear/reset all child controls within a usercontrol from code behind asp net c# 我如何获得C#asp.net在运行时中创建的所有控件的值 - how can i get value of all controls created in runtime in C# asp.net 如何修复代码只在 .NET C# 中选择当前表中的所有 asp:CheckBoxList 与“JQuery - Select All CheckBoxes within...”问题相同? - How to fix code have select all asp:CheckBoxList within current table only in .NET C# same as "JQuery - Select All CheckBoxes within..." question? C#.Net中的Obout控件 - Obout controls in C# .Net 如何一次选择多个控件(按钮)C# - How do I select multiple controls(buttons) at a time c# C# 如何将“全选”选项添加到类似于 MS Excel 中的“全选”选项的 CheckedListBox - C# How do you add a “Select All” option to a CheckedListBox that works like the “Select All” option in MS Excel 如何使用C#获取内容页面中的所有控件? - How to get all controls in Content Page with C#? 如何使用C#在运行时从表单获取所有控件? - How to get all controls from a form at runtime in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM