Beispiel #1
0
        protected void append_onclick(p5.Void btn, EventArgs e)
        {
            CurrentEdit = null;
            var widget = List.CreatePersistentControl <p5.Literal> ("x" + (_next++), List.Controls.Count);

            widget.Element    = "li";
            widget["onclick"] = "item_onclick";
            widget.innerValue = Txt["value"];
        }
        protected void sandbox_invoke_insert_child_check_exist_2_onclick(p5.Container container, EventArgs e)
        {
            var existing = new List <p5.Literal> (container.ControlsOfType <p5.Literal> ());

            if (existing.Count != 2)
            {
                throw new ApplicationException("widget disappeared somehow");
            }

            if (existing [0].innerValue != "howdy world")
            {
                throw new ApplicationException("widget had wrong innerValue");
            }

            if (existing [1].innerValue != "foo")
            {
                throw new ApplicationException("widget had wrong innerValue");
            }

            var literal = container.CreatePersistentControl <p5.Literal> (null, 1);

            literal.Element    = "strong";
            literal.innerValue = "howdy world 2";

            existing = new List <p5.Literal> (container.ControlsOfType <p5.Literal> ());
            if (existing.Count != 3)
            {
                throw new ApplicationException("widget disappeared somehow after insertion");
            }

            if (existing [1].innerValue != "howdy world 2")
            {
                throw new ApplicationException("widget had wrong innerValue");
            }
        }
        protected void sandbox_invoke_insert_child_check_exist_1_onclick(p5.Container container, EventArgs e)
        {
            var literal = container.CreatePersistentControl <p5.Literal> (null, 0);

            literal.Element    = "strong";
            literal.innerValue = "howdy world";
        }
        protected void myBtn_onclick(p5.Literal sender, EventArgs e)
        {
            var lit1 = Container2.CreatePersistentControl <p5.Literal> ();

            lit1.Element     = "option";
            lit1["value"]    = "Option3";
            lit1.innerValue  = "Option 3";
            lit1["selected"] = null;

            var lit2 = Container2.CreatePersistentControl <p5.Literal> ();

            lit2.Element    = "option";
            lit2["value"]   = "Option4";
            lit2.innerValue = "Option 4";

            select_change(Container2, e);
        }
        protected void sandbox_invoke_append_remove_onclick(p5.Container container, EventArgs e)
        {
            var literals = new List <p5.Literal> (container.ControlsOfType <p5.Literal> ());

            container.RemoveControlPersistent(literals [0]);
            var literal = container.CreatePersistentControl <p5.Literal> (null, 0);

            literal.Element    = "strong";
            literal.innerValue = "howdy world";
        }
        protected void sandbox_invoke_add_similar_onclick(p5.Container container, EventArgs e)
        {
            // removing one controls
            container.RemoveControlPersistentAt(0);  // sandbox_invoke_remove_many_2

            // adding another control with same ID
            var lit1 = container.CreatePersistentControl <p5.Literal> ("sandbox_invoke_add_similar_child", 0);

            lit1.Element    = "strong";
            lit1.innerValue = "howdy";
        }
        protected void sandbox_invoke_remove_many_onclick(p5.Container container, EventArgs e)
        {
            // removing three controls
            container.RemoveControlPersistentAt(1);                                                           // sandbox_invoke_remove_many_2
            ((p5.Container)container.Controls [1]).RemoveControlPersistentAt(2);                              // sandbox_invoke_remove_many_6
            ((p5.Container)((p5.Container)container.Controls [1]).Controls [1]).RemoveControlPersistentAt(1); // sandbox_invoke_remove_many_9

            // creating two new controls

            // parent is sandbox_invoke_remove_many
            var lit1 = container.CreatePersistentControl <p5.Literal> (null, 0);

            lit1.Element    = "strong";
            lit1.innerValue = "howdy";

            // parent is sandbox_invoke_remove_many_5
            var lit2 = ((p5.Container)((p5.Container)container.Controls [2]).Controls [1]).CreatePersistentControl <p5.Literal> ();

            lit2.Element    = "em";
            lit2.innerValue = "world";
        }