When we want to find a control by its ID, chances are it is usually nested in many levels. In this scenario, we need more powerful method than the .NET framework provided Control.FindControl.
Writing such a method actually is straightforward enough:
private static Control FindControlByID(Control root, string id)
if (id == string.Empty)
if (root.ID == id)
foreach (Control c in root.Controls)
Control t = FindControlByID(c, id);
if (t != null)
It works great no matter there is master page involved or not; no matter how many levels the control hierarchy has.