源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

递归输出ASP.NET页面所有控件的类型和ID的代码

  • 时间:2022-11-02 07:43 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:递归输出ASP.NET页面所有控件的类型和ID的代码
写一个方法:
[u]复制代码[/u] 代码如下:
private void DisplayAllControl(Control control, int step) { foreach (Control ctl in control.Controls) { string s = new string('-', step * 4) + ctl.GetType().Name + "〈" + ctl.ID + "〉"; Response.Write(s + "<br/>"); if (ctl.HasControls()) DisplayAllControl(ctl, step + 1); } }
调用: DisplayAllControl(this.Page, 0); 执行该方法后,会在页面中分层输出所有控件的类型和ID值,即使是GridView、母版页、用户控件里的控件也不例外。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部