MasterPage下的FindControl
2009-02-21 22:51
411 查看
好久没写递归了,范了个很低级的错误,T。T
下面这段话引自nobugs
FindeControl所有容器有关(只搜索当前的容器)
MSDN的解释:
FindControl 方法可用于访问在设计时其 ID 不可用的控件。此方法只搜索页的直接或顶级容器;它不在页所包含的命名容器中递归搜索控件。若要访问从属命名容器中的控件,请调用该容器的 FindControl 方法。
那么想当然的就是通过递归来找了,然后我自己写了个结果不行,就是我开头说的白痴错误。
Rick Strahl有详细的解释,地址:http://west-wind.com/WebLog/posts/5127.aspx
他的代码:
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
下面这段话引自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; }
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
相关文章推荐
- PreviousPage.FindControl遇到MasterPage查找控件的方法
- 当PreviousPage.FindControl遇到MasterPage,如何查找控件?
- PreviousPage.FindControl遇到MasterPage查找控件的方法
- 使用MasterPage后的this.FindControl()函数的问题
- asp.net MasterPage FindControl
- this.PreviousPage.FindControl遇到MasterPage,如何查找控件?
- 解决使用MasterPage后,Page.FindControl方法找不到指定控件的问题
- 解决使用MasterPage后,Page.FindControl方法找不到指定控件的问题
- 解决使用MasterPage后,Page.FindControl方法找不到指定控件的问题
- Page.Master.FindControl?还是Page.FindControl?
- 【转】当PreviousPage.FindControl遇到MasterPage,如何查找控件
- 使用MasterPage后的this.FindControl()函数的问题
- Event in Master Page, Content Page and User Control
- asp.net中的跨页发送(利用PreviousPage.FindControl()方法取值)
- amixer: Unable to find simple control 'Master',0
- ASP.NET的Page指令, Master指令,Control指令,Register指令,PreviousPageType指令,MasterType指令
- How to programmatically assign a SkinID to a control while using a master page in ASP.net 2.0
- Page.FindControl(string id) 与母版页结合后发现的一个问题
- asp.net 2.0中tablecontrol搭配masterpage的小bug
- Master指令,Control指令,Register指令,PreviousPageType指令,MasterType指令