惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
J
Java Code Geeks
G
Google Developers Blog
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
L
LangChain Blog
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Vercel News
Vercel News
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Y
Y Combinator Blog
博客园_首页
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
A
About on SuperTechFans
B
Blog
Microsoft Security Blog
Microsoft Security Blog

博客园 - 林614

IIS问题:Server Application Error 的解决 实现自己的ProviderBase UML建模的要点总结 软件企业致胜的18种成功模式 自定义协议的注册及程序示例(C#) Remoting事件处理全接触 Marshal、Disconnect与生命周期以及跟踪服务 Net Remoting基础篇 在没有 IIS 的条件下运行 ASMX ASP.NET MVC学习笔记 C#位运算 匹配css 样式的正则表达式 System.Web.Mvc.HtmlHelper学习及应用 正则表达式提取HTML页面的特定部分 - 林614 - 博客园 服务器应用程序不可用的解决方法 - 林614 - 博客园 体验.NET2.0的优雅之Provider应用 最窄770px最宽1024px经典布局 调试找不到文件的解决方法 FindControl查找内容页上的某个控件 - 林614 - 博客园
遍历页面所有控件的方式
林614 · 2009-01-17 · via 博客园 - 林614

private void ClearAllText(System.Web.UI.Control contrl)
  {
      int ctl_count=contrl.Controls.Count;
   for (int i=0;i<ctl_count;i++) 
   {
    foreach(Control ctl in contrl.Controls[i].Controls)
    {
     if (ctl.HasControls())
     {
      ClearAllText(ctl.Parent);
     }
     else
     {
      if (ctl is TextBox)
       (ctl as TextBox).Text="";
     }
    }
   }
  }
 在页面中添加一个按钮,调用此函数,参数为this.Page,如:

ClearAllText(this.Page);