///
/// Finds a Control recursively. Note finds the first match and exists
///
///
///
///
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;
}
with this the code becomes:
///
/// Assigns controls from the subclassed control to this instance so
/// we always can access the controls in our base class.
///
protected void AssignControls()
{
this.lblError = wwWebUtils.FindControlRecursive(this.Master,"lblError") as Label;
this.dgItemList = wwWebUtils.FindControlRecursive(this.Master, "dgItemList") as DataGrid;
}
No comments:
Post a Comment