asp.net page is also a control. how can I access child control within page control?
this.page.?
asp.net page is also a control. how can I access child control within page control?
this.page.?
Try this :
Control childControl = Page.FindControl("YourControlsID");
You can access it via the Controls Collection
Page.Controls
Recursive FindControls from Rick Strahl's Blog
public static Control FindControlRecursive(Control Root, string Id)
{
if (Root.ID == Id)
return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
Be careful with this however... This is not a method you want to be using inside a loop or anything.