Ejemplo n.º 1
0
        public void ChildControlsOfType()
        {
            var userControl = new UserControl {ID = "uc"};
            var panel = new Panel {ID = "pl"};
            var htmlUl = new HtmlGenericControl("ul") {ID = "ul"};
            var htmlLi = new HtmlGenericControl("li") {ID = "li"};
            htmlLi.Controls.Add(new CheckBox {ID = "ckb1"});
            htmlUl.Controls.Add(htmlLi);
            panel.Controls.Add(htmlUl);
            panel.Controls.Add(new CheckBox {ID = "ckb2"});
            userControl.Controls.Add(panel);

            var checkBoxes = userControl.Controls<CheckBox>();
            Assert.AreEqual(2, checkBoxes.Count());
            Console.Write("Found: ");
            checkBoxes.ToList().ForEach(ckb => Console.Write(ckb.ID + ", "));
        }