heisetoufa 发表于 2013-2-4 22:10:12

c# asp.net 遍历母板下所有控件,获取获得遍历母板下所有Label控件,后台递归获取前台控件

遍历母板下所有控件,递归方式

private void GetControls(Control c){if (c is Label)Response.Write(c.ID + "<br />");if (c.HasControls())foreach (Control con in c.Controls)GetControls(con);}

如果知道父控件,获取控件所要的开销会小很多

黑色头发:http://heisetoufa.iteye.com/
页: [1]
查看完整版本: c# asp.net 遍历母板下所有控件,获取获得遍历母板下所有Label控件,后台递归获取前台控件