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

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 小乔的闺房

学习ID,ClientID,UniqueID 基础知识1 (2)最简单的Remoting程序 (1)将对象序列化为bin,soap,xml (4)迭代器 (3)集合接口 (1)学习数组,集合,IEnumerable接口,引申学习迭代器 (2)学习集合,引申学习索引器和泛型 自定义服务器控件(1)整体把握(未完待续) location详解 使用ASP.NET AJAX实现(图片)幻灯片效果 固定GridView列字符串长度,多于的用...代替 读取Excel数据到GridView相关问题(待完善) 说明nchar(10),char(10),nvarchar(10),varchar(10) syscolumns 获得数据库里所有表的名称 类[属性扩展],属性[属性扩展](待完善) 获得数据库表的列数 WebForm里弹出警告框之内的自定义类MessageBox
FindControl实现原理
小乔的闺房 · 2007-10-22 · via 博客园 - 小乔的闺房

public virtual Control FindControl(string id)
{
    return this.FindControl(id, 0);
}

protected virtual Control FindControl(string id, int pathOffset)
{
    string text;
    this.EnsureChildControls();//确定当前控件是否包含子控件,如果不包含,则创建子控件。
    if (!this.flags[0x80])//如果当前控件没有实现INamingContainer接口.
    {
        Control namingContainer = this.NamingContainer;//根据控件树,获取当前控件的父控件
        if (namingContainer != null)//有父控件
        {
            return namingContainer.FindControl(id, pathOffset);//从父控件开始FindControl
        }
        return null;//没有父控件,返回null
    }
    if (this.HasControls() && (this._occasionalFields.NamedControls == null))//有子控件
    {
        this.EnsureNamedControlsTable();//确保所有子控件都被正确加载完成
    }
    if ((this._occasionalFields == null) || (this._occasionalFields.NamedControls == null))//没有子控件
    {
        return null;//返回null
    }
    //开始匹配
    char[] anyOf = new char[] { '$', ':' };
    int num = id.IndexOfAny(anyOf, pathOffset);
    if (num == -1)//未找到
    {
        text = id.Substring(pathOffset);
        return (this._occasionalFields.NamedControls[text] as Control);
    }
    text = id.Substring(pathOffset, num - pathOffset);
    Control control2 = this._occasionalFields.NamedControls[text] as Control;
    if (control2 == null)
    {
        return null;
    }
    return control2.FindControl(id, num + 1);
}

FindControl只在实现了INamingContainer接口的类中查找控件.
见这个例子("http://www.latter.cn/asp/show/20050422/18/3959375.html")

INamingContainer 接口
任何实现该接口的控件都创建一个新的命名空间,在这个新的命名空间中,所有子控件ID属性在整个应用程序内保证是唯一的.
由该接口提供的标记允许在支持数据绑定的Web服务器控件内唯一命名动态生成的服务器控件实例.
这些控件包括Repeater,DataGrid,DataList,CheckBoxList,ChangePassword,LoginView,Menu,SiteMapNodeItem及RadioButtonList控件.
在开发模板化控件时,应实现该接口以避免同一页上的命名冲突.