MasterPage下的FindControl

简介:

FindeControl所有容器有关(只搜索当前的容器) 
MSDN的解释: 
FindControl 方法可用于访问在设计时其 ID 不可用的控件。此方法只搜索页的直接或顶级容器;它不在页所包含的命名容器中递归搜索控件。若要访问从属命名容器中的控件,请调用该容器的 FindControl 方法。

那么想当然的就是通过递归来找了,然后我自己写了个结果不行,就是我开头说的白痴错误。

Rick Strahl有详细的解释,地址:http://west-wind.com/WebLog/posts/5127.aspx

他的代码:

        public static Control FindControl(Control root, string id)
        {
            if (root.ID == id) return root;
            foreach (Control c in root.Controls)
            {
                Control foundC= FindControl(c, id);
                if (foundC != null)
                    return foundC;
            }
            return null;
        }
本文转自today4king博客园博客,原文链接:http://www.cnblogs.com/jinzhao/archive/2009/02/21/1395590.html,如需转载请自行联系原作者
相关文章
|
4月前
|
关系型数据库 MySQL 数据库
你真的知道Show Master Status吗?
你真的知道Show Master Status吗?
71 1
|
12月前
|
机器学习/深度学习 传感器 人工智能
GE           V7668A-1310B0 350-9310007668-131020 D 
GE           V7668A-1310B0 350-9310007668-131020 D 
40 0
|
Unix Linux AI芯片
4.3.3 info page
4.3.3 info page
92 0
My FioriTest navigation from master page to detail page
Created by Wang, Jerry, last modified on Feb 16, 2015
118 0
My FioriTest navigation from master page to detail page
|
存储 缓存 算法
我们还需要Page Cache么?
作者:齐江 杨艇艇 马涛
1097 0