Пример #1
0
 public Control ExtendedFindChildControl(string strid, FindControlType type, Type ReturnControlType)
 {
     Control objContentPlaceHolder = this.Page.Form.FindControl("ContentPlaceHolder1");
     if (objContentPlaceHolder != null)
     {
         return this.FindChildControl(strid, objContentPlaceHolder, type, ReturnControlType);
     }
     else
     {
         return this.FindChildControl(strid, this.Page.Form, type, ReturnControlType);
     }
 }
Пример #2
0
 public List<Control> ExtendedFindChildControls(string strid, FindControlType type, Type ReturnControlType)
 {
     Control objContentPlaceHolder = this.DesignMode ? this.Page.FindControl("ContentPlaceHolder1") : this.Page.Form.FindControl("ContentPlaceHolder1");
     if (objContentPlaceHolder != null)
     {
         return this.FindChildControls(strid, objContentPlaceHolder, type, ReturnControlType);
     }
     else
     {
         if (this.DesignMode)
             return this.FindChildControls(strid, this.Page, type, ReturnControlType);
         else
             return this.FindChildControls(strid, this.Page.Form, type, ReturnControlType);
     }
 }
Пример #3
0
        internal List<Control> FindChildControls(string strid, Control ct, FindControlType type, Type ReturnControlType)
        {
            List<Control> lControls = new List<Control>();
            string fieldName = "ID";
            if (type == FindControlType.DataSourceID)
            {
                fieldName = "DataSourceID";
            }
            else if (type == FindControlType.BindingObject)
            {
                fieldName = "BindingObject";
            }
            else if (type == FindControlType.MasterDataSource)
            {
                fieldName = "MasterDataSource";
            }

            Type ctType = ct.GetType();
            PropertyInfo pi = ctType.GetProperty(fieldName);
            if (pi != null && pi.GetValue(ct, null) != null && pi.GetValue(ct, null).ToString() == strid && ReturnControlType.IsInstanceOfType(ct))
            {
                lControls.Add(ct);
            }
            else
            {
                if (ct.HasControls())
                {
                    foreach (Control ctchild in ct.Controls)
                    {
                        Control ctrtn = FindChildControl(strid, ctchild, type, ReturnControlType);
                        if (ctrtn != null)
                        {
                            lControls.Add(ctrtn);
                        }
                    }
                }
                else
                {
                    return null;
                }
            }
            return lControls;
        }