Friday, June 3, 2016

Find a Parent Control Recursively In C#.Net

//Parent Control Recursively
private static Control FindControlParent(Control control, Type type)
        {
            Control ctrlParent = control;
            while((ctrlParent = ctrlParent.Parent) != null)
            {
                if(ctrlParent.GetType() == type)
                {
                    return ctrlParent;
                }
            }
            return null;
        }

No comments: