zoukankan      html  css  js  c++  java
  • MasterPage下的FindControl

    好久没写递归了,范了个很低级的错误,T。T

    下面这段话引自nobugs

    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;
            }
    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    Linux下常用的3种软件安装方式
    解决navicate 连接mysql数据库中文乱码的问题
    Lua 遍历Linux目录下的文件夹
    ubuntu 更改源
    ubuntu 下安装配置LAMP
    简述configure、pkg-config、pkg_config_path三者的关系
    linux 下库的深入调研
    Linux下的库操作工具-nm、ar、ldd、ldconfig和ld.so
    linux命令strings
    c++隐式类型转换和explicit
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1395590.html
Copyright © 2011-2022 走看看