[求助]怎样统计页面中有多少个Button控件
怎样在代码中实现,谢谢!
循环窗体,判断控件类型,代码如下:
int count;
foreach(System.Web.UI.Control control in this.Controls)
{
if(control.GetType().ToString()=="System.Web.UI.HtmlControls.HtmlForm")
{
foreach(System.Web.UI.Control controls in control.Controls)
{
if(controlTxt.GetType().ToString()=="System.Web.UI.WebControls.Button")
{
count++;
}
}
}
}
Response.Write(count.ToString());