protected void Page_Load(object sender, EventArgs e)
{
/* 找到所有控件
Response.Write("Page_Load<br/>");
string str = "";
foreach (Control item in Page.Controls)
{
str+=item.GetType() + " " + item.ID + "<br/>";
}
Response.Write(str);
* */
//找到LiteralControl控件的text内容。
/*
foreach (Control item in Page.Controls)
{
if (item is LiteralControl)
{
Response.Write(((LiteralControl)item).Text);
}
}*/
//递归遍历 可以找到控件里面的控件
GetContent(Page.Controls);
}
protected void GetContent(ControlCollection controls)
{
foreach (Control item in controls)
{
Response.Write(item.ToString() + "-----<br/>");
if (item.Controls!=null)
{
GetContent(item.Controls);
}
}
}