/// <summary>
        /// Goes through the form and returns a list of all control on a form
        /// that are marked as [Localizable]
        ///
        /// This internal method does all the work and drills into child containers
        /// recursively.
        /// </summary>
        /// <param name="control">The control at which to start parsing usually Page</param>
        /// <param name="ResourceList">An instance of the resource list. Pass null to create</param>
        /// <returns></returns>
        protected List <LocalizableProperty> GetAllLocalizableControls(Control control, List <LocalizableProperty> ResourceList, bool noControlRecursion)
        {
            if (control == null)
            {
                control = this.Page;
            }

            // On the first hit create the list - recursive calls pass in the list
            if (ResourceList == null)
            {
                ResourceList = new List <LocalizableProperty>();
            }

            // 'generated' controls don't have an ID and don't need to be localized
            if (control.ID != null)
            {
                // Read all public properties and search for Localizable Attribute
                PropertyInfo[] pi = control.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                foreach (PropertyInfo property in pi)
                {
                    object[] Attributes = property.GetCustomAttributes(typeof(LocalizableAttribute), true);
                    if (Attributes.Length < 1)
                    {
                        continue;
                    }

                    LocalizableProperty lp = new LocalizableProperty();

                    lp.ControlId = control.ID;

                    if (lp.ControlId.StartsWith("__"))
                    {
                        lp.ControlId = lp.ControlId.Substring(2);
                    }

                    lp.Property = property.Name;
                    lp.Value    = property.GetValue(control, null) as string;

                    ResourceList.Add(lp);
                }

                /// Check for special properties that not marked as [Localizable]
                GetNonLocalizableControlProperties(control, ResourceList);
            }

            if (!noControlRecursion)
            {
                // Now drill into the any contained controls
                foreach (Control ctl in control.Controls)
                {
                    // Recurse into child controls
                    if (ctl != null)
                    {
                        this.GetAllLocalizableControls(ctl, ResourceList);
                    }
                }
            }

            return(ResourceList);
        }
        /// <summary>
        /// Goes through the form and returns a list of all control on a form
        /// that are marked as [Localizable]
        /// 
        /// This internal method does all the work and drills into child containers
        /// recursively.
        /// </summary>
        /// <param name="control">The control at which to start parsing usually Page</param>
        /// <param name="ResourceList">An instance of the resource list. Pass null to create</param>
        /// <returns></returns>
        protected List<LocalizableProperty> GetAllLocalizableControls(Control control, List<LocalizableProperty> ResourceList, bool noControlRecursion)
        {
            if (control == null)
                control = this.Page;

            // On the first hit create the list - recursive calls pass in the list
            if (ResourceList == null)
                ResourceList = new List<LocalizableProperty>();

            // 'generated' controls don't have an ID and don't need to be localized
            if (control.ID != null)
            {
                // Read all public properties and search for Localizable Attribute
                PropertyInfo[] pi = control.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                foreach (PropertyInfo property in pi)
                {
                    object[] Attributes = property.GetCustomAttributes(typeof(LocalizableAttribute), true);
                    if (Attributes.Length < 1)
                        continue;

                    LocalizableProperty lp = new LocalizableProperty();

                    lp.ControlId = control.ID;

                    if (lp.ControlId.StartsWith("__"))
                        lp.ControlId = lp.ControlId.Substring(2);

                    lp.Property = property.Name;
                    lp.Value = property.GetValue(control, null) as string;

                    ResourceList.Add(lp);
                }

                /// Check for special properties that not marked as [Localizable]
                GetNonLocalizableControlProperties(control, ResourceList);
            }

            if (!noControlRecursion)
            {
                // Now drill into the any contained controls
                foreach (Control ctl in control.Controls)
                {
                    // Recurse into child controls
                    if (ctl != null)
                        this.GetAllLocalizableControls(ctl, ResourceList);
                }
            }

            return ResourceList;
        }
        /// <summary>
        /// This method is responsible for showing localization icons next to every control
        /// that has localizable properties.
        ///
        /// The icons are resource based and also display the control's ID. Note icons are
        /// placed only next to any controls that are marked as [Localizable]. Some contained
        /// controls like GridVIew/DataGrid Columns are not marked as [Localizable] yet
        /// the ASP.NET designer creates implicit resources for them anyway - these controls
        /// will not show icons.
        /// </summary>
        /// <param name="control"></param>
        /// <param name="TopLevel"></param>
        public void AddLocalizationIcons(Control control, bool TopLevel)
        {
            if (control == null)
            {
                control = this.Page;
            }

            string IconUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), GlobalizationResources.INFO_ICON_LOCALIZE);

            if (TopLevel)
            {
                this.AddIconScriptFunctions();

                // *** Embed the IconUrl
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), control.ID + "_iu",
                                                             "var _IconUrl = '" + IconUrl + "';\r\n", true);
            }

            // *** Don't localize ourselves
            if (control is wwDbResourceControl)
            {
                return;
            }


            // *** 'generated' controls don't have an ID and don't need to be localized
            if (control.ID != null)
            {
                // *** Read all public properties and search for Localizable Attribute
                PropertyInfo[] pi = control.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                foreach (PropertyInfo property in pi)
                {
                    // *** Check for localizable Attribute on the property
                    object[] Attributes = property.GetCustomAttributes(typeof(LocalizableAttribute), true);
                    if (Attributes.Length < 1)
                    {
                        continue;
                    }

                    LocalizableProperty lp = new LocalizableProperty();
                    lp.ControlId = control.ID;

                    if (lp.ControlId.StartsWith("__"))
                    {
                        lp.ControlId = lp.ControlId.Substring(2);
                    }

                    lp.Property = property.Name;
                    lp.Value    = property.GetValue(control, null) as string;

                    string ResourceSet = control.TemplateControl.AppRelativeVirtualPath.Replace("~/", "");

                    //string Html = "<img src='"  + IconUrl +
                    //           "' onclick=\"OnLocalization('" + control.ID + "','" + ResourceSet + "','"+ lp.Property + "');\" style='margin-left:3px;border:none;' title='" + control.ID + "' >";

                    string Html = "<img src={0} onclick=\"OnLocalization('" + control.ID + "','" + ResourceSet + "','" + lp.Property + "');\" style='margin-left:3px;border:none;' title='" + control.ID + "' >";
                    Html = string.Format(Html.Replace("'", @"\'"), "' + _IconUrl + '");

                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), control.ClientID + "_ahac",
                                                                 string.Format("AddHtmlAfterControl('{0}','{1}');\r\n", control.ClientID, Html), true);

                    break;
                }
            }

            // *** Now loop through all child controls
            foreach (Control ctl in control.Controls)
            {
                // *** Recurse into child controls
                if (ctl != null)
                {
                    this.AddLocalizationIcons(ctl, false);
                }
            }
        }