int cntControl = this.Page.Controls.Count;
StringBuilder sb = new StringBuilder();
sb.Append("<table border='1' style='width:500px;'>");
for (int i = 0; i < cntControl ; i++)
{
foreach (Control ctrl in this.Page.Controls[i].Controls)
{
if (ctrl is Button)
{
if (ctrl.ID.Substring(0, 3).Equals("btn"))
{
sb.Append("<tr><td>" + ctrl.ID + "</td></tr>");
}
else
{
sb.Append("<tr><td><span style='color:red;'>" + ctrl.ID + "</span></td></tr>");
}
}
if (ctrl is GridView)
{
if (ctrl.ID.Substring(0, 3).Equals("gvw"))
{
sb.Append("<tr><td>" + ctrl.ID + "</td></tr>");
}
else
{
sb.Append("<tr><td><span style='color:red;backgroud-color:yellow'>" + ctrl.ID + "</span></td></tr>");
}
}
}
}
sb.Append("</table>");
Label lblPageCheck = new Label();
lblPageCheck.Text = sb.ToString();
Page.Controls.Add(lblPageCheck);