写一个方法:

 1 private void DisplayAllControl(Control control, int step)
2 {
3 foreach (Control ctl in control.Controls)
4 {
5 string s = new string('-', step * 4) + ctl.GetType().Name + "" + ctl.ID + "";
6 Response.Write(s + "<br/>");
7 if (ctl.HasControls())
8 DisplayAllControl(ctl, step + 1);
9 }
10 }

调用:

DisplayAllControl(this.Page, 0);

执行该方法后,会在页面中分层输出所有控件的类型和ID值,即使是GridView、母版页、用户控件里的控件也不例外。

相关文章:

  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-01-09
猜你喜欢
  • 2022-12-23
  • 2021-09-06
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-06-09
相关资源
相似解决方案