Reputation: 5114
Just wondering if there is a way to select all controls/items in asp.net/c# like $('*') performed in jQuery
Upvotes: 0
Views: 182
Reputation: 46997
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;
}
}
Upvotes: 1