HasControls() public method

public HasControls ( ) : bool
return bool
Example #1
0
 internal Control FindChildControl(string strid, Control ct)
 {
     if (ct.ID == strid)
     {
         return ct;
     }
     else
     {
         if (ct.HasControls())
         {
             foreach (Control ctchild in ct.Controls)
             {
                 Control ctrtn = FindChildControl(strid, ctchild);
                 if (ctrtn != null)
                 {
                     return ctrtn;
                 }
             }
             return null;
         }
         else
         {
             return null;
         }
     }
 }
        public static void ClearControls(ref Control control)
        {
            if (control == null)
                return;

            if (control is TextBox)
            {
                ((TextBox)control).Text = string.Empty;
                return;
            }

            else if (control is DropDownList)
            {
                ((DropDownList)control).SelectedIndex = 0;
                return;
            }

            if (control.HasControls())
            {
                foreach (Control c in control.Controls)
                {
                    Control ctrl = c;
                    ClearControls(ref ctrl);
                }
            }
        }
Example #3
0
 private Control GetWebValidateBox(Control ct)
 {
     if (ct is WebValidate)
     {
         return ct;
     }
     else if (ct.HasControls())
     {
         foreach (Control ctchild in ct.Controls)
         {
             if (ctchild is WebValidate)
             {
                 return ctchild;
             }
             else
             {
                 GetWebValidateBox(ctchild);
             }
         }
         return null;
     }
     else
     {
         return null;
     }
 }
Example #4
0
        public static void ClearForm(Control container, FormClearOptions option, bool check_nc)
        {
            try
            {
                switch (option)
                {
                    case FormClearOptions.ClearAll:

                        if (check_nc)
                        {
                            if (container.ID != null)
                                if (container.ID.EndsWith("_nc"))
                                    break;
                        }

                        if (container.GetType().Equals(typeof(TextBox)))
                        {
                            TextBox txtBox = ((TextBox)container);
                            txtBox.Text = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(DropDownList)))
                        {
                            DropDownList ddl = ((DropDownList)container);
                            ddl.SelectedValue = string.Empty;
                        }
                        else if (container.GetType().Equals(typeof(CheckBox)))
                        {
                            CheckBox chk = ((CheckBox)container);
                            chk.Checked = false;
                        }
                        else if (container.GetType().Equals(typeof(RadioButtonList)))
                        {
                            RadioButtonList rbl = ((RadioButtonList)container);
                            rbl.SelectedIndex = -1;
                        }
                        else if (container.GetType().Equals(typeof(RadioButton)))
                        {
                            RadioButton rb = ((RadioButton)container);
                            rb.Checked = false;
                        }
                        else if (container.HasControls())
                        {
                            foreach (Control ctrl in container.Controls)
                                ClearForm(ctrl, option, check_nc);
                        }
                        break;

                    default:
                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
 private static string Crawl(Control objControl, int intLevel)
 {
     string result = new string('-',intLevel) + objControl.ClientID + "<br>";
     if(objControl.HasControls())
     {
         foreach(Control c in objControl.Controls)
             result += Crawl(c,intLevel + 1);
     }
     return result;
 }
 public static void SetViewState(Control container)
 {
     container.ViewStateMode= ViewStateMode.Disabled;
     if (container.HasControls())
     {
         foreach(Control ctrl in container.Controls)
         {
             Control control = ctrl;
             SetViewState(control);
         }
     }
 }
 /// <summary>
 /// Recursively gets every control of the specified root (including root and all it's child controls).
 /// Returns the controls as an array of Control objects.
 /// </summary>
 /// <param name="root">The root control to get child controls for.</param>
 /// <returns>An array of all the child controls of root.</returns>
 public static Control[] getAllPageControls(Control root)
 {
     List<Control> list = new List<Control>();
     list.Add(root);
     if (root.HasControls())
     {
         foreach (Control control in root.Controls)
         {
             list.AddRange(getAllPageControls(control));
         }
     }
     return list.ToArray();
 }
Example #8
0
 public static Control[] FlattenHierachy(Control root)
 {
     List<Control> list = new List<Control>();
     list.Add(root);
     if (root.HasControls())
     {
         foreach (Control control in root.Controls)
         {
             list.AddRange(FlattenHierachy(control));
         }
     }
     return list.ToArray();
 }
        private static Control InjectDependenciesRecursiveInternal(IApplicationContext appContext, Control control)
        {
            if (control is LiteralControl) return control; // nothing to do

            ISupportsWebDependencyInjection diControl = control as ISupportsWebDependencyInjection;
            if (diControl != null && diControl.DefaultApplicationContext != null)
            {
                return control; // nothing to do anymore - control cares for itself and its children
            }

            // "intercept" Control to make it DI-aware
            ControlInterceptor.EnsureControlIntercepted(appContext, control);

            // if the control is a UserControl, use ApplicationContext from it's physical location
            IApplicationContext appContextToUse = appContext;
            UserControl userControl = control as UserControl;
            if (userControl != null)
            {
                appContextToUse = GetControlApplicationContext(appContext, userControl);
            }

            // set ApplicationContext instance
            if (control is IApplicationContextAware)
            {
                ((IApplicationContextAware)control).ApplicationContext = appContextToUse;
            }

            // inject dependencies using control's context
            control = (Control)appContextToUse.ConfigureObject(control, control.GetType().FullName);

            // and now go for control's children
            if (control.HasControls())
            {
                ControlCollection childControls = control.Controls;
                int childCount = childControls.Count;
                for (int i = 0; i < childCount; i++)
                {
                    Control c = childControls[i];
                    if (c is LiteralControl) continue;

                    Control configuredControl = InjectDependenciesRecursiveInternal(appContext, c);
                    if (configuredControl != c)
                    {
                        ControlAccessor ac = new ControlAccessor(c.Parent);
                        ac.SetControlAt(configuredControl, i);
                    }
                }
            }

            return control;
        }
        /// <summary>
        /// Get all page controls, recursively, ignoring irrelevant controls.
        /// </summary>
        public static Control[] FlattenHierachy(Control root)
        {
            if (IgnoreControl(root)) return new Control[0];

            var list = new List<Control>() { root };

            if (root.HasControls())
            {
                foreach (Control c in root.Controls)
                {
                    list.AddRange(FlattenHierachy(c));
                }
            }

            return list.ToArray();
        }
Example #11
0
 public void HookOnFocus(Control CurrentControl)
 {
     //checks if control is one of TextBox, DropDownList, ListBox or Button
     if ((CurrentControl is TextBox) ||
         (CurrentControl is DropDownList) ||
         (CurrentControl is ListBox) ||
         (CurrentControl is Button))
         //adds a script which saves active control on receiving focus
         //in the hidden field __LASTFOCUS.
         (CurrentControl as WebControl).Attributes.Add(
            "onfocus",
            "try{document.getElementById('__LASTFOCUS').value=this.id} catch(e) {}");
     //checks if the control has children
     if (CurrentControl.HasControls())
         //if yes do them all recursively
         foreach (Control CurrentChildControl in CurrentControl.Controls)
             HookOnFocus(CurrentChildControl);
 }
Example #12
0
 /// <summary>
 /// Verifies that <paramref name="ctrl"/> has no child controls.
 /// </summary>
 public static void HasNoControls(Control ctrl)
 {
     Assert.IsNotNull(ctrl);
     Assert.IsFalse(ctrl.HasControls(),
                   "Control {0} has child controls",
                   ctrl.ID);
 }
		Control FindByType (Control parent, Type type)
		{
			if (!parent.HasControls ())
				return null;

			foreach (Control c in parent.Controls) {
				if (type.IsAssignableFrom (c.GetType ()))
					return c;

				Control ret = FindByType (c, type);
				if (ret != null)
					return ret;
			}
			return null;
		}
 private Control findControl(Control parent, string id)
 {
     if (parent.HasControls())
     {
         Control control = parent.FindControl(id);
         if (control != null)
         {
             return control;
         }
         foreach (Control control2 in parent.Controls)
         {
             control = this.findControl(control2, id);
             if (control != null)
             {
                 return control;
             }
         }
     }
     return null;
 }
Example #15
0
 /// <summary>
 /// Verifies that <paramref name="ctrl"/> has child controls.
 /// </summary>		
 public static void HasControls(Control ctrl)
 {
     Assert.IsNotNull(ctrl);
     Assert.IsTrue(ctrl.HasControls(),
                   "Control {0} has no controls",
                   ctrl.ID);
 }
        void AddResourceAttributesToControl(Control control, string property, string resourceSet)
        {

                    if (control is WebControl)
                    {
                        var ctl = control as WebControl;
                        ctl.Attributes["data-resource-id"] = control.ID + "." + property;
                        ctl.Attributes["data-resource-set"] = resourceSet;
                    }
                    else if (control is Literal)  // literal and localize don't have wrapping tags so add them
                    {
                        var ctl = control as Literal;                        
                        ctl.Text = string.Format("<span data-resource-id=\"{0}\" data-resource-set=\"{1}\">" +
                                   ctl.Text +
                                   "</span>", control.ID + "." + property, resourceSet);
                    }
                    else if (control is HtmlControl)
                    {
                        var ctl = control as HtmlControl;
                        ctl.Attributes["data-resource-id"] = control.ID + "." + property;
                        ctl.Attributes["data-resource-set"] = resourceSet;
                    }
     
                    else
                    {
                        if (control.HasControls() && !(control is Page || control is HtmlForm))
                        {
                            control.Controls.AddAt(0, new Literal()
                            {
                                Text = string.Format("<span data-resource-id=\"{0}\" data-resoure-set=\"{1}\">",control.ID + "." + property, resourceSet)                            
                            });
                            control.Controls.Add(new Literal() {Text = "</span>" });
                        }
                    }

        }
        // Renders hidden variables for IPostBackDataHandlers which are
        // not displayed due to pagination or secondary UI.
        /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderOffPageVariables"]/*' />
        protected void RenderOffPageVariables(XhtmlMobileTextWriter writer, Control control, int page) {
            if (control.HasControls()) {
                foreach (Control child in control.Controls) {
                    // Note: Control.Form != null.
                    if (!child.Visible || child == Control.Form.Header || child == Control.Form.Footer) {
                        continue;
                    }

                    MobileControl mobileCtl = child as MobileControl;

                    if (mobileCtl != null) {
                        if (mobileCtl.IsVisibleOnPage(page)
                            && (mobileCtl == ((XhtmlFormAdapter)mobileCtl.Form.Adapter).SecondaryUIControl ||
                            null == ((XhtmlFormAdapter)mobileCtl.Form.Adapter).SecondaryUIControl)) {
                            if (mobileCtl.FirstPage == mobileCtl.LastPage) {
                                // Entire control is visible on this page, so no need to look
                                // into children.
                                continue;
                            }

                            // Control takes up more than one page, so it may be possible that
                            // its children are on a different page, so we'll continue to
                            // fall through into children.
                        }
                        else if (mobileCtl is IPostBackDataHandler) {
                            XhtmlControlAdapter adapter = mobileCtl.Adapter as XhtmlControlAdapter;
                            if (adapter != null) {
                                adapter.RenderAsHiddenInputField(writer);
                            }
                        }
                    }
                    RenderOffPageVariables(writer, child, page);
                }
            }
        }
Example #18
0
        /// <summary>
        /// <para>ProcessControl peforms the high level localization for a single control and optionally it's children.</para>
        /// </summary>
        /// <param name="control">Control to find the AttributeCollection on</param>
        /// <param name="affectedControls">ArrayList that hold the controls that have been localized. This is later used for the removal of the key attribute.</param>				
        /// <param name="includeChildren">If true, causes this method to process children of this controls.</param>
        /// <param name="resourceFileRoot">Root Resource File.</param>
        internal void ProcessControl(Control control, ArrayList affectedControls, bool includeChildren, string resourceFileRoot)
        {
            if (!control.Visible) return;

            //Perform the substitution if a key was found
            string key = GetControlAttribute(control, affectedControls, Localization.KeyName);
            if (!string.IsNullOrEmpty(key))
            {
                //Translation starts here ....
                string value = Localization.GetString(key, resourceFileRoot);
                if (control is Label)
                {
                    var label = (Label)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        label.Text = value;
                    }
                }
                if (control is LinkButton)
                {
                    var linkButton = (LinkButton)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        MatchCollection imgMatches = Regex.Matches(value, "<(a|link|img|script|input|form).[^>]*(href|src|action)=(\\\"|'|)(.[^\\\"']*)(\\\"|'|)[^>]*>", RegexOptions.IgnoreCase);
                        foreach (Match match in imgMatches)
                        {
                            if ((match.Groups[match.Groups.Count - 2].Value.IndexOf("~", StringComparison.Ordinal) != -1))
                            {
                                string resolvedUrl = Page.ResolveUrl(match.Groups[match.Groups.Count - 2].Value);
                                value = value.Replace(match.Groups[match.Groups.Count - 2].Value, resolvedUrl);
                            }
                        }
                        linkButton.Text = value;
                        if (string.IsNullOrEmpty(linkButton.ToolTip))
                        {
                            linkButton.ToolTip = value;
                        }
                    }
                }
                if (control is HyperLink)
                {
                    var hyperLink = (HyperLink)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        hyperLink.Text = value;
                    }
                }
                if (control is ImageButton)
                {
                    var imageButton = (ImageButton)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        imageButton.AlternateText = value;
                    }
                }
                if (control is Button)
                {
                    var button = (Button)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        button.Text = value;
                    }
                }
                if (control is HtmlButton)
                {
                    var button = (HtmlButton)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        button.Attributes["Title"] = value;
                    }
                }
                if (control is HtmlImage)
                {
                    var htmlImage = (HtmlImage)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        htmlImage.Alt = value;
                    }
                }
                if (control is CheckBox)
                {
                    var checkBox = (CheckBox)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        checkBox.Text = value;
                    }
                }
                if (control is BaseValidator)
                {
                    var baseValidator = (BaseValidator)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        baseValidator.ErrorMessage = value;
                    }
                }
                if (control is Image)
                {
                    var image = (Image)control;
                    if (!String.IsNullOrEmpty(value))
                    {
                        image.AlternateText = value;
                        image.ToolTip = value;
                    }
                }
            }

            //Translate listcontrol items here 
            if (control is ListControl)
            {
                var listControl = (ListControl)control;
                for (int i = 0; i <= listControl.Items.Count - 1; i++)
                {
                    AttributeCollection attributeCollection = listControl.Items[i].Attributes;
                    key = attributeCollection[Localization.KeyName];
                    if (key != null)
                    {
                        string value = Localization.GetString(key, resourceFileRoot);
                        if (!String.IsNullOrEmpty(value))
                        {
                            listControl.Items[i].Text = value;
                        }
                    }
                    if (key != null && affectedControls != null)
                    {
                        affectedControls.Add(attributeCollection);
                    }
                }
            }


            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            if (control is Image)
            {
                var image = (Image)control;
                if (image.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1)
                {
                    image.ImageUrl = Page.ResolveUrl(image.ImageUrl);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(image.ImageUrl))
                {
                    string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    image.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            if (control is HtmlImage)
            {
                var htmlImage = (HtmlImage)control;
                if (htmlImage.Src.IndexOf("~", StringComparison.Ordinal) != -1)
                {
                    htmlImage.Src = Page.ResolveUrl(htmlImage.Src);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(htmlImage.Src))
                {
                    string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    htmlImage.Src = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            if (control is HyperLink)
            {
                HyperLink ctrl;
                ctrl = (HyperLink)control;
                if ((ctrl.NavigateUrl.IndexOf("~", StringComparison.Ordinal) != -1))
                {
                    ctrl.NavigateUrl = Page.ResolveUrl(ctrl.NavigateUrl);
                }
                if ((ctrl.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1))
                {
                    ctrl.ImageUrl = Page.ResolveUrl(ctrl.ImageUrl);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(ctrl.ImageUrl))
                {
                    string iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    string iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    string iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    ctrl.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //Process child controls
            if (includeChildren && control.HasControls())
            {
                var objModuleControl = control as IModuleControl;
                if (objModuleControl == null)
                {
                    PropertyInfo pi = control.GetType().GetProperty("LocalResourceFile");
                    if (pi != null && pi.GetValue(control, null) != null)
                    {
                        //If controls has a LocalResourceFile property use this
                        IterateControls(control.Controls, affectedControls, pi.GetValue(control, null).ToString());
                    }
                    else
                    {
                        //Pass Resource File Root through
                        IterateControls(control.Controls, affectedControls, resourceFileRoot);
                    }
                }
                else
                {
                    //Get Resource File Root from Controls LocalResourceFile Property
                    IterateControls(control.Controls, affectedControls, objModuleControl.LocalResourceFile);
                }
            }
        }
 private static void SetControlPageRecursive(Control control, int page)
 {
     MobileControl mc = control as MobileControl;
     if(mc != null)
     {
         mc.FirstPage = page;
         mc.LastPage = page;
     }
     if (control.HasControls())
     {
         foreach (Control child in control.Controls)
         {
             MobileControl mobileChild = child as MobileControl;
             if (mobileChild != null)
             {
                     mobileChild.FirstPage = page;
                     mobileChild.LastPage = page;
             }
             else 
             {
                 SetControlPageRecursive(child, page);
             }
         }
     }
 }
Example #20
0
 private Control GetAllCtrls(string strid, Control ct)
 {
     if (ct.ID == strid)
     {
         return ct;
     }
     else
     {
         if (ct.HasControls())
         {
             foreach (Control ctchild in ct.Controls)
             {
                 Control ctrtn = GetAllCtrls(strid, ctchild);
                 if (ctrtn != null)
                 {
                     return ctrtn;
                 }
             }
             return null;
         }
         else
         {
             return null;
         }
     }
 }
Example #21
0
        public static void ClearForm(Control container, List<Type> controlTypes)
        {
            if (container.GetType().Equals(typeof(Label)))
            {
                Label lbl = ((Label)container);
            }

            else if (container.HasControls())
            {
                foreach (Control ctrl in container.Controls)
                    ClearForm(ctrl, controlTypes);
            }
        }
 // Toggles the editability of the web controls on the page
 private void ToggleControls(Control c)
 {
     if (c.HasControls())
     {
         foreach (Control control in c.Controls)
         {
             ToggleControls(control);
         }
     }
     else
     {
         if (c.ID != "Title")  // Don't let the Title be changeable
         {
             var textBox = c as TextBox;
             if (textBox != null)
             {
                 textBox.Enabled = !textBox.Enabled;
             }
             var checkBox = c as CheckBox;
             if (checkBox != null)
             {
                 checkBox.Enabled = !checkBox.Enabled;
             }
         }
     }
 }
Example #23
0
 private  void searchContentPlaceHolder(Control ctrl, List<string> lst)
 {
     if (ctrl is ContentPlaceHolder)
         lst.Add(ctrl.ClientID);
     else if (ctrl.HasControls())
         foreach (Control c in ctrl.Controls)
             searchContentPlaceHolder(c, lst);
 }
 /// <summary>
 /// 验证控件权限。
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="permissions"></param>
 protected virtual void VerifyPermissions(Control ctrl, SecurityPermissionCollection permissions)
 {
     if (ctrl != null && ctrl.HasControls())
     {
         foreach (Control ctr in ctrl.Controls)
         {
             if (ctr is WebControl)
                 this.VerifyPermissionControls(ctr, permissions);
             this.VerifyPermissions(ctr, permissions);
         }
     }
 }
Example #25
0
        /// <summary>
        /// <para>ProcessControl peforms the high level localization for a single control and optionally it's children.</para>
        /// </summary>
        /// <param name="control">Control to find the AttributeCollection on</param>
        /// <param name="affectedControls">ArrayList that hold the controls that have been localized. This is later used for the removal of the key attribute.</param>				
        /// <param name="includeChildren">If true, causes this method to process children of this controls.</param>
        /// <param name="resourceFileRoot">Root Resource File.</param>
        internal void ProcessControl(Control control, ArrayList affectedControls, bool includeChildren, string resourceFileRoot)
        {
            if (!control.Visible) return;

            //Perform the substitution if a key was found
            var key = GetControlAttribute(control, affectedControls, Localization.KeyName);
            if (!string.IsNullOrEmpty(key))
            {
                //Translation starts here ....
                var value = Localization.GetString(key, resourceFileRoot);
                LocalizeControl(control, value);
            }

            //Translate listcontrol items here 
            var listControl = control as ListControl;
            if (listControl != null)
            {
                for (var i = 0; i <= listControl.Items.Count - 1; i++)
                {
                    var attributeCollection = listControl.Items[i].Attributes;
                    key = attributeCollection[Localization.KeyName];
                    if (key != null)
                    {
                        var value = Localization.GetString(key, resourceFileRoot);
                        if (!String.IsNullOrEmpty(value))
                        {
                            listControl.Items[i].Text = value;
                        }
                    }
                    if (key != null && affectedControls != null)
                    {
                        affectedControls.Add(attributeCollection);
                    }
                }
            }


            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            var image = control as Image;
            if (image != null)
            {
                if (image.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1)
                {
                    image.ImageUrl = Page.ResolveUrl(image.ImageUrl);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(image.ImageUrl))
                {
                    var iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    var iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    var iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    image.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            var htmlImage = control as HtmlImage;
            if (htmlImage != null)
            {
                if (htmlImage.Src.IndexOf("~", StringComparison.Ordinal) != -1)
                {
                    htmlImage.Src = Page.ResolveUrl(htmlImage.Src);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(htmlImage.Src))
                {
                    var iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    var iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    var iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    htmlImage.Src = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //UrlRewriting Issue - ResolveClientUrl gets called instead of ResolveUrl
            //Manual Override to ResolveUrl
            var ctrl = control as HyperLink;
            if (ctrl != null)
            {
                if ((ctrl.NavigateUrl.IndexOf("~", StringComparison.Ordinal) != -1))
                {
                    ctrl.NavigateUrl = Page.ResolveUrl(ctrl.NavigateUrl);
                }
                if ((ctrl.ImageUrl.IndexOf("~", StringComparison.Ordinal) != -1))
                {
                    ctrl.ImageUrl = Page.ResolveUrl(ctrl.ImageUrl);
                }

                //Check for IconKey
                if (string.IsNullOrEmpty(ctrl.ImageUrl))
                {
                    var iconKey = GetControlAttribute(control, affectedControls, IconController.IconKeyName);
                    var iconSize = GetControlAttribute(control, affectedControls, IconController.IconSizeName);
                    var iconStyle = GetControlAttribute(control, affectedControls, IconController.IconStyleName);
                    ctrl.ImageUrl = IconController.IconURL(iconKey, iconSize, iconStyle);
                }
            }

            //Process child controls
            if (!includeChildren || !control.HasControls()) return;
            var objModuleControl = control as IModuleControl;
            if (objModuleControl == null)
            {
                var pi = control.GetType().GetProperty("LocalResourceFile");
                if (pi != null && pi.GetValue(control, null) != null)
                {
                    //If controls has a LocalResourceFile property use this
                    IterateControls(control.Controls, affectedControls, pi.GetValue(control, null).ToString());
                }
                else
                {
                    //Pass Resource File Root through
                    IterateControls(control.Controls, affectedControls, resourceFileRoot);
                }
            }
            else
            {
                //Get Resource File Root from Controls LocalResourceFile Property
                IterateControls(control.Controls, affectedControls, objModuleControl.LocalResourceFile);
            }
        }
 internal static void SerializeInnerContents(Control control, IDesignerHost host, ObjectPersistData persistData, TextWriter writer, string filter)
 {
     PersistChildrenAttribute attribute = (PersistChildrenAttribute) TypeDescriptor.GetAttributes(control)[typeof(PersistChildrenAttribute)];
     ParseChildrenAttribute attribute2 = (ParseChildrenAttribute) TypeDescriptor.GetAttributes(control)[typeof(ParseChildrenAttribute)];
     if (attribute.Persist || (!attribute2.ChildrenAsProperties && control.HasControls()))
     {
         for (int i = 0; i < control.Controls.Count; i++)
         {
             SerializeControl(control.Controls[i], host, writer, string.Empty);
         }
     }
     else
     {
         SerializeInnerProperties(control, host, persistData, writer, filter);
     }
 }
Example #27
0
        // 2009/07/21-start

        #region コントロール取得&イベントハンドラ設定

        /// <summary>コントロール取得&イベントハンドラ設定(下位互換)</summary>
        /// <param name="ctrl">コントロール</param>
        /// <param name="prefix">プレフィックス</param>
        /// <param name="eventHandler">イベント ハンドラ</param>
        /// <param name="controlHt">ディクショナリ</param>
        internal static void GetCtrlAndSetClickEventHandler(
            Control ctrl, string prefix, object eventHandler, Dictionary<string, Control> controlHt)
        {
            #region チェック処理

            // コントロール指定が無い場合
            if (ctrl == null)
            {
                // 何もしないで戻る。
                return;
            }

            // プレフィックス指定が無い場合
            if (prefix == null || prefix == "")
            {
                // 何もしないで戻る。
                return;
            }

            #endregion

            #region コントロール取得&イベントハンドラ設定

            // コントロールのIDチェック
            if (ctrl.ID == null)
            {
                // コントロールID無し
            }
            else
            {
                // コントロールID有り

                // コントロールのID長確認
                if (prefix.Length <= ctrl.ID.Length)
                {
                    // 指定のプレフィックス
                    if (prefix == ctrl.ID.Substring(0, prefix.Length))
                    {
                        // イベントハンドラを設定する。
                        if (prefix == GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX))
                        {
                            // CHECK BOX
                            CheckBox checkBox = FxCmnFunction.CastByAsOperator<CheckBox>(ctrl, prefix);

                            // ハンドラをキャストして設定
                            checkBox.CheckedChanged += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                    }
                }
            }

            #endregion

            #region 再帰

            // 子コントロールがある場合、
            if (ctrl.HasControls())
            {
                // 子コントロール毎に
                foreach (Control childCtrl in ctrl.Controls)
                {
                    // 再帰する。
                    MyCmnFunction.GetCtrlAndSetClickEventHandler(childCtrl, prefix, eventHandler, controlHt);
                }
            }

            #endregion
        }
 private Control RecursiveFindControl (Control ctrl, string p)
 {
     if (ctrl.ID == p)
         return ctrl;
     if (ctrl.HasControls())
     {
         foreach (Control c in ctrl.Controls)
         {
             Control foundC = RecursiveFindControl(c, p);
             if (foundC != null)
                 return foundC;
         }
     }
     return null;
 }
Example #29
0
        // 2009/07/21-start

        #region コントロール取得&イベントハンドラ設定

        /// <summary>コントロール取得&イベントハンドラ設定(下位互換)</summary>
        /// <param name="ctrl">コントロール</param>
        /// <param name="prefix">プレフィックス</param>
        /// <param name="eventHandler">イベント ハンドラ</param>
        /// <param name="controlHt">ディクショナリ</param>
        internal static void GetCtrlAndSetClickEventHandler(
            Control ctrl, string prefix, object eventHandler, Dictionary<string, Control> controlHt)
        {
            #region チェック処理

            // コントロール指定が無い場合
            if (ctrl == null)
            {
                // 何もしないで戻る。
                return;
            }

            // プレフィックス指定が無い場合
            if (prefix == null || prefix == "")
            {
                // 何もしないで戻る。
                return;
            }

            #endregion

            #region コントロール取得&イベントハンドラ設定

            // コントロールのIDチェック
            if (ctrl.ID == null)
            {
                // コントロールID無し
            }
            else
            {
                // コントロールID有り

                // コントロールのID長確認
                if (prefix.Length <= ctrl.ID.Length)
                {
                    // 指定のプレフィックス
                    if (prefix == ctrl.ID.Substring(0, prefix.Length))
                    {
                        // イベントハンドラを設定する。
                        if (prefix == GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX))
                        {
                            // CHECK BOX
                            CheckBox checkBox = null;

                            try
                            {
                                // キャストできる
                                checkBox = (CheckBox)ctrl;
                            }
                            catch (Exception ex)
                            {
                                // キャストできない
                                throw new FrameworkException(
                                    FrameworkExceptionMessage.CONTROL_TYPE_ERROR[0],
                                    String.Format(FrameworkExceptionMessage.CONTROL_TYPE_ERROR[1],
                                    prefix, ctrl.GetType().ToString()), ex);
                            }

                            checkBox.CheckedChanged += (EventHandler)eventHandler;

                            // ディクショナリに格納
                            // ControlHt.Add(ctrl.ID, ctrl);
                            // ControlHt[ctrl.ID] = ctrl;
                            FxCmnFunction.AddControlToDic(ctrl, controlHt); // 2011/02/12
                        }
                    }
                }
            }

            #endregion

            #region 再帰

            // 子コントロールがある場合、
            if (ctrl.HasControls())
            {
                // 子コントロール毎に
                foreach (Control childCtrl in ctrl.Controls)
                {
                    // 再帰する。
                    MyCmnFunction.GetCtrlAndSetClickEventHandler(childCtrl, prefix, eventHandler, controlHt);
                }
            }

            #endregion
        }
Example #30
0
		} // end protected Control FindWizardControl(string id)

		/// <summary>
		/// Find Wizard Control - Find a control in a wizard, is recursive
		/// </summary>
		/// <param name="srcCtrl">Source/Root Control</param>
		/// <param name="id">ID of target control</param>
		/// <returns>A Control, if found; null, if not</returns>
		protected Control FindWizardControl(Control srcCtrl, string id)
		{
			Control ctrlRtn = srcCtrl.FindControl(id);

			if (ctrlRtn == null)
			{
				if (srcCtrl.HasControls())
				{
					int nbrCtrls = srcCtrl.Controls.Count;
					for (int i = 0; i < nbrCtrls; i++)
					{
						// Check all child controls of srcCtrl
						ctrlRtn = FindWizardControl(srcCtrl.Controls[i], id);
						if (ctrlRtn != null) break;
					} // endfor (int i=0; i < nbrCtrls; i++)
				} // endif (HasControls)

			} // endif (ctrlRtn == null)

			return ctrlRtn;
		} // end protected Control FindWizardControl(Control srcCtrl, string id)