public static Control FindChildControlByClientID(Control seed, string clientID) { if (seed == null || string.IsNullOrEmpty(clientID)) { return((Control)null); } Control control1 = (Control)null; foreach (Control control2 in seed.Controls) { string str1 = control2.ID ?? ""; string str2 = control2.ClientID ?? ""; if (clientID.Equals(str1) || clientID.Equals(str2)) { control1 = control2; } else if (ControlUtils.HasControls(control2)) { control1 = ControlUtils.FindChildControlByClientID(control2, clientID); } if (control1 != null) { break; } } return(control1); }
public static Control FindChildControl(Control seed, string id) { if (seed == null || string.IsNullOrEmpty(id)) { return((Control)null); } Control control1 = (Control)null; try { control1 = seed.FindControl(id); if (control1 != null) { return(control1); } } catch (HttpException ex) { } foreach (Control control2 in seed.Controls) { if (ControlUtils.HasControls(control2)) { control1 = ControlUtils.FindChildControl(control2, id); } if (control1 != null) { break; } } return(control1); }
public static Control FindChildControl(Control seed, string typeFullName, bool shallow) { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return((Control)null); } Control control1 = (Control)null; foreach (Control control2 in seed.Controls) { if (ReflectionUtils.IsTypeOf((object)control2, typeFullName, shallow)) { control1 = control2; } else if (ControlUtils.HasControls(control2)) { control1 = ControlUtils.FindChildControl(control2, typeFullName, shallow); } if (control1 != null) { break; } } return(control1); }
public static Control FindChildControlByClientID(Control seed, string clientID) { if (seed == null || string.IsNullOrEmpty(clientID)) { return(null); } Control found = null; string tempID = ""; string tempClientID = ""; foreach (Control control in seed.Controls) { tempID = control.ID ?? ""; tempClientID = control.ClientID ?? ""; if (clientID.Equals(tempID) || clientID.Equals(tempClientID)) { found = control; } else if (ControlUtils.HasControls(control)) { found = ControlUtils.FindChildControlByClientID(control, clientID); } if (found != null) { break; } } return(found); }
private static Control FindControl(Control seed, string id, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(id)) { return(null); } Control found = null; try { found = seed.FindControl(id); if (found != null) { return(found); } } catch (HttpException) { /// TODO: Notes regarding the FindControl Method. // We need to call the native .FindControl because .EnsureChildControls() // can only be called internally by a Control. // If protected .FindControl finds the control, we just return the found control. // There is a bug in Visual Studio Design-Mode which causes protected/native // .FindControl to think it's found two controls with the same ID, although only // one exists. The conflict appears to be coming from a cached version of the assembly. // Might be related to the following Microsoft KB834608 article, see // http://support.microsoft.com/default.aspx/kb/834608 // start checking .ID property } Control root = (seed is INamingContainer) ? seed : seed.NamingContainer; string exclude = (branch != null) ? branch.ID ?? "" : ""; foreach (Control control in root.Controls) { if (!exclude.Equals(control.ID) && ControlUtils.HasControls(control)) { found = ControlUtils.FindChildControl(control, id); } if (found != null) { break; } } if (traverse && found == null) { found = ControlUtils.FindControl(root.NamingContainer, id, traverse, root); } return(found); }
public static List <T> FindControls <T>(Control seed, string typeFullName, bool shallow) where T : Control { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return(null); } seed = (seed is INamingContainer) ? seed : seed.NamingContainer; List <T> foundControls = new List <T>(); foreach (Control control in seed.Controls) { if (ReflectionUtils.IsTypeOf(control, typeFullName, shallow)) { foundControls.Add(control as T); } if (ControlUtils.HasControls(control)) { foundControls.AddRange(ControlUtils.FindChildControls <T>(control, typeFullName, shallow)); } } return(foundControls); }
public static Control FindChildControl(Control seed, string typeFullName, bool shallow) { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return(null); } Control found = null; foreach (Control control in seed.Controls) { if (ReflectionUtils.IsTypeOf(control, typeFullName, shallow)) { found = control; } else if (ControlUtils.HasControls(control)) { found = ControlUtils.FindChildControl(control, typeFullName, shallow); } if (found != null) { break; } } return(found); }
/* Misc * -----------------------------------------------------------------------------------------------*/ public static Control FindControlByClientID(Control seed, string clientID, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(clientID)) { return(null); } Control parent = (seed is INamingContainer) ? seed : seed.NamingContainer; if (clientID.Equals(parent.ClientID ?? "")) { return(parent); } Control found = null; string exclude = (branch != null) ? branch.ClientID ?? "" : ""; string tempID = ""; string tempClientID = ""; List <Control> waiting = new List <Control>(); foreach (Control c in parent.Controls) { tempID = c.ID ?? ""; tempClientID = c.ClientID ?? ""; if (clientID.Equals(tempID) || clientID.Equals(tempClientID)) { found = c; } else if (ControlUtils.HasControls(c) && (exclude.IsEmpty() || !exclude.Equals(tempClientID))) { found = ControlUtils.FindChildControlByClientID(c, clientID); } if (found != null) { break; } } if (traverse && found == null) { found = ControlUtils.FindControlByClientID(parent.NamingContainer, clientID, true, parent); } return(found); }
private static Control FindControlByTypeName( Control seed, string typeFullName, bool shallow, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return((Control)null); } Control branch1 = seed is INamingContainer ? seed : seed.NamingContainer; if (ReflectionUtils.IsTypeOf((object)branch1, typeFullName, shallow)) { return(branch1); } Control control1 = (Control)null; string str = branch != null ? branch.ID ?? "" : ""; foreach (Control control2 in branch1.Controls) { if (!str.Equals(control2.ID)) { if (ReflectionUtils.IsTypeOf((object)control2, typeFullName, shallow)) { control1 = control2; } else if (ControlUtils.HasControls(control2)) { control1 = ControlUtils.FindChildControl(control2, typeFullName, shallow); } if (control1 != null) { break; } } } if (traverse && control1 == null) { control1 = ControlUtils.FindControlByTypeName(branch1.NamingContainer, typeFullName, shallow, traverse, branch1); } return(control1); }
private static Control FindControlByTypeName(Control seed, string typeFullName, bool shallow, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return(null); } Control root = (seed is INamingContainer) ? seed : seed.NamingContainer; if (ReflectionUtils.IsTypeOf(root, typeFullName, shallow)) { return(root); } Control found = null; string exclude = (branch != null) ? branch.ID ?? "" : ""; foreach (Control control in root.Controls) { if (!exclude.Equals(control.ID)) { if (ReflectionUtils.IsTypeOf(control, typeFullName, shallow)) { found = control; } else if (ControlUtils.HasControls(control)) { found = ControlUtils.FindChildControl(control, typeFullName, shallow); } if (found != null) { break; } } } if (traverse && found == null) { found = ControlUtils.FindControlByTypeName(root.NamingContainer, typeFullName, shallow, traverse, root); } return(found); }
public static Control FindControlByClientID( Control seed, string clientID, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(clientID)) { return((Control)null); } Control branch1 = seed is INamingContainer ? seed : seed.NamingContainer; if (clientID.Equals(branch1.ClientID ?? "")) { return(branch1); } Control control1 = (Control)null; string text = branch != null ? branch.ClientID ?? "" : ""; List <Control> controlList = new List <Control>(); foreach (Control control2 in branch1.Controls) { string str1 = control2.ID ?? ""; string str2 = control2.ClientID ?? ""; if (clientID.Equals(str1) || clientID.Equals(str2)) { control1 = control2; } else if (ControlUtils.HasControls(control2) && (text.IsEmpty() || !text.Equals(str2))) { control1 = ControlUtils.FindChildControlByClientID(control2, clientID); } if (control1 != null) { break; } } if (traverse && control1 == null) { control1 = ControlUtils.FindControlByClientID(branch1.NamingContainer, clientID, true, branch1); } return(control1); }
private static Control FindControl( Control seed, string id, bool traverse, Control branch) { if (seed == null || string.IsNullOrEmpty(id)) { return((Control)null); } Control control1 = (Control)null; try { control1 = seed.FindControl(id); if (control1 != null) { return(control1); } } catch (HttpException ex) { } Control branch1 = seed is INamingContainer ? seed : seed.NamingContainer; string str = branch != null ? branch.ID ?? "" : ""; foreach (Control control2 in branch1.Controls) { if (!str.Equals(control2.ID) && ControlUtils.HasControls(control2)) { control1 = ControlUtils.FindChildControl(control2, id); } if (control1 != null) { break; } } if (traverse && control1 == null) { control1 = ControlUtils.FindControl(branch1.NamingContainer, id, traverse, branch1); } return(control1); }
public static List <T> FindChildControls <T>(Control seed, string typeFullName, bool shallow) where T : Control { if (seed == null || string.IsNullOrEmpty(typeFullName)) { return((List <T>)null); } List <T> objList = new List <T>(); foreach (Control control in seed.Controls) { if (ReflectionUtils.IsTypeOf((object)control, typeFullName, shallow)) { objList.Add(control as T); } if (ControlUtils.HasControls(control)) { objList.AddRange((IEnumerable <T>)ControlUtils.FindChildControls <T>(control, typeFullName, shallow)); } } return(objList); }
public static List <T> FindControls <T>(Control seed, bool shallow) where T : Control { if (seed == null) { return((List <T>)null); } seed = seed is INamingContainer ? seed : seed.NamingContainer; List <T> objList = new List <T>(); foreach (Control control in seed.Controls) { if (ReflectionUtils.IsTypeOf((object)control, typeof(T), shallow)) { objList.Add(control as T); } if (ControlUtils.HasControls(control)) { objList.AddRange((IEnumerable <T>)ControlUtils.FindChildControls <T>(control, shallow)); } } return(objList); }
/* FindChildControl * -----------------------------------------------------------------------------------------------*/ public static Control FindChildControl(Control seed, string id) { if (seed == null || string.IsNullOrEmpty(id)) { return(null); } Control found = null; try { found = seed.FindControl(id); if (found != null) { return(found); } } catch (HttpException) { } foreach (Control control in seed.Controls) { if (ControlUtils.HasControls(control)) { found = ControlUtils.FindChildControl(control, id); } if (found != null) { break; } } return(found); }
public static List <T> FindChildControls <T>(Control seed, bool shallow) where T : Control { if (seed == null) { return(null); } List <T> foundControls = new List <T>(); foreach (Control control in seed.Controls) { if (ReflectionUtils.IsTypeOf(control, typeof(T), shallow)) { foundControls.Add(control as T); } if (ControlUtils.HasControls(control)) { foundControls.AddRange(ControlUtils.FindChildControls <T>(control, shallow)); } } return(foundControls); }