Reputation: 4759
asp.net page is also a control. how can I access child control within page control?
this.page.?
Upvotes: 3
Views: 262
Reputation: 44916
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.
Upvotes: 3
Reputation: 48098
Try this :
Control childControl = Page.FindControl("YourControlsID");
Upvotes: 5