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;
}
}
精彩评论