开发者

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

开发者 https://www.devze.com 2023-03-13 06:57 出处:网络
Just wonder开发者_如何转开发ing if there is a way to select all controls/items in asp.net/c# like $(\'*\') performed in jQueryvar allCtrls = GetChildren(Page);

Just wonder开发者_如何转开发ing if there is a way to select all controls/items in asp.net/c# like $('*') performed in 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;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消