Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /*  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);
        }
Ejemplo n.º 4
0
        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);
        }