1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
public static System.Web.UI.Control FindControlRecursive(System.Web.UI.Control root, string id)
{
if (root.ID == id )
{
return root;
}
foreach (System.Web.UI.Control childControls in root.Controls)
{
System.Web.UI.Control temp = FindControlRecursive(childControls, id);
if (temp != null)
{
return temp;
}
}
return null;
}
public System.Web.UI.Control FindControlInAllParents(System.Web.UI.Control root, string id)
{
System.Web.UI.Control temp = null;
while (root != null)
{
temp = FindControlRecursive(root, id);
if (temp == null)
{
root = root.Parent;
}
else
{
root = null;
}
}
return temp;
}
|