获取某容器中所有的服务器控件
public class GetControls
{
public List<System.Web.UI.Control> controls = new List<System.Web.UI.Control>();
public List<System.Web.UI.Control> GetAll(System.Web.UI.Control control)
{
if (control != null)
{
controls.Add(control);
if (control.HasControls())
{
foreach (System.Web.UI.Control cont in control.Controls)
{
GetAll(cont);
}
}
}
return controls;
}
}