开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜