private void UpdateValidationGroup(Person p)
        {
            ControlCollection cc = Controls;

            cc.OfType <LinkButton>().ToList().ForEach(c => c.ValidationGroup += p.Id);
            cc.OfType <RegularExpressionValidator>().ToList().ForEach(c => c.ValidationGroup += p.Id);
            cc.OfType <RequiredFieldValidator>().ToList().ForEach(c => c.ValidationGroup     += p.Id);
            cc.OfType <ValidationSummary>().ToList().ForEach(c => c.ValidationGroup          += p.Id);
            cc.OfType <Button>().ToList().ForEach(c => c.ValidationGroup += p.Id);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets or adds a <see cref="Control"/> to the <see cref="ControlCollection"/>.
        /// </summary>
        /// <typeparam name="TControl"></typeparam>
        /// <param name="controls"></param>
        /// <param name="predicate"></param>
        /// <param name="create"></param>
        /// <returns></returns>
        public static TControl GetOrAdd <TControl>(this ControlCollection controls, Predicate <TControl> predicate, Func <TControl> create)
            where TControl : Control
        {
            if (controls == null)
            {
                throw new ArgumentNullException(nameof(controls));
            }
            if (predicate == null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }
            if (create == null)
            {
                throw new ArgumentNullException(nameof(create));
            }

            // find existing
            var control = controls
                          .OfType <TControl>()
                          .Where(i => predicate(i))
                          .FirstOrDefault();

            // add new
            if (control == null)
            {
                controls.Add(control = create());
            }

            return(control);
        }
Ejemplo n.º 3
0
        private void UnwindGroupBoxes(GroupBox delete, ControlCollection controls)
        {
            List <Control> controls_ = new List <Control>();

            controls_.AddRange(controls.OfType <Control>());
            foreach (Control c in controls_)
            {
                if (delete != null)
                {
                    //delete.Controls.Remove(c);
                    Controls.Add(c);
                }

                if (typeof(GroupBox).IsAssignableFrom(c.GetType()))
                {
                    UnwindGroupBoxes((GroupBox)c, c.Controls);
                }
            }

            if (delete != null)
            {
                delete.Controls.Clear();
                Controls.Remove(delete);
                delete.Dispose();
            }
        }
Ejemplo n.º 4
0
    public override void SetupControl(ControlCollection controls)
    {
        var cotrol = controls.OfType <Label>().First(c => c.ID == "lbl");

        cotrol.Visible = true;
        cotrol.Text    = Text;
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Clears the text from control.
        /// </summary>
        /// <typeparam name="C"></typeparam>
        /// <param name="controls">The controls.</param>
        public static void ClearCollection <C>(ControlCollection controls) where C : ITextControl
        {
            IEnumerable <C> enumBoxes = controls.OfType <C>();
            List <C>        boxes     = enumBoxes.ToList();

            foreach (C box in boxes)
            {
                box.Text = string.Empty;
            }
        }
Ejemplo n.º 6
0
        // Reset all textboxes except the timer interval and the percentage
        public void ClearTextBoxes(ControlCollection controls)
        {
            foreach (TextBox tb in controls.OfType <TextBox>())
            {
                if (tb.Name != "TextBoxTimeInterval" && tb.Name != "TextBoxWarnPercentage")
                {
                    tb.Text = "0";
                }
            }

            foreach (Control c in controls)
            {
                this.ClearTextBoxes(c.Controls);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Clears Text from Controls...ie TextBox, Label, anything that implements ITextBox
        /// </summary>
        /// <typeparam name="T">Collection Type, ie. ContentPlaceHolder..</typeparam>
        /// <typeparam name="C">ie TextBox, Label, anything that implements ITextBox</typeparam>
        /// <param name="controls"></param>
        public static void Clear <T, C>(ControlCollection controls)
            where C : ITextControl
            where T : Control
        {
            IEnumerable <T> placeHolders = controls.OfType <T>();
            List <T>        holders      = placeHolders.ToList();

            foreach (T holder in holders)
            {
                IEnumerable <C> enumBoxes = holder.Controls.OfType <C>();
                List <C>        boxes     = enumBoxes.ToList();

                foreach (C box in boxes)
                {
                    box.Text = string.Empty;
                }
            }
        }
Ejemplo n.º 8
0
    private static T FindWebPart <T>(ControlCollection childControls)
    {
        // first level
        var webParts = childControls.OfType <T>();

        if (webParts.Any())
        {
            return(webParts.First());
        }

        foreach (Control control in childControls)
        {
            var webPart = FindWebPart <T>(control.Controls);
            if (webPart != null)
            {
                return(webPart);
            }
        }

        return(default(T));
    }
Ejemplo n.º 9
0
        RibbonControl FindRibbon(ControlCollection controls)
        {
            RibbonControl res = controls.OfType <Control>().FirstOrDefault(x => x is RibbonControl) as RibbonControl;

            if (res != null)
            {
                return(res);
            }
            foreach (Control control in controls)
            {
                if (control.HasChildren)
                {
                    res = FindRibbon(control.Controls);
                    if (res != null)
                    {
                        return(res);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
 public static IEnumerable <ControlBase> GetValidItems(this ControlCollection source)
 {
     return(source.OfType <Control>().Where(c => c.Tag is ControlBase).Select(c => c.Tag as ControlBase).Where(c => c.IsValid));
 }