Beispiel #1
0
        public static void IsChildControlStateCleared_Load(Page p)
        {
            ControlWithState c1 = new ControlWithState();

            p.Form.Controls.Add(c1);
            if (p.IsPostBack)
            {
                Assert.IsFalse(c1.IsChildControlStateCleared, "ControlState#1");
                c1.ClearChildControlState();
                Assert.IsTrue(c1.IsChildControlStateCleared, "ControlState#1");
            }
            ControlWithState c2 = new ControlWithState();

            c1.Controls.Add(c2);
            ControlWithState c3 = new ControlWithState();

            c2.Controls.Add(c3);
            if (p.IsPostBack)
            {
                Assert.IsFalse(c2.IsChildControlStateCleared, "ControlState#1");
                Assert.IsFalse(c3.IsChildControlStateCleared, "ControlState#1");
            }
            if (!p.IsPostBack)
            {
                c1.State = "State";
                c2.State = "Cool";
                c3.State = "SubCool";
            }
        }
Beispiel #2
0
        public static void ClearChildState_Load(Page p)
        {
            ControlWithState c1 = new ControlWithState();

            p.Form.Controls.Add(c1);
            if (p.IsPostBack)
            {
                c1.ClearChildState();
            }
            ControlWithState c2 = new ControlWithState();

            c1.Controls.Add(c2);
            ControlWithState c3 = new ControlWithState();

            c2.Controls.Add(c3);
            if (!p.IsPostBack)
            {
                c1.State     = "State";
                c2.State     = "Cool";
                c2.Viewstate = "Very Cool";
                c3.State     = "SubCool";
                c3.Viewstate = "Super Cool";
            }
            else
            {
                Assert.AreEqual("State", c1.State, "ClearChildState#1");
                Assert.AreEqual(null, c2.State, "ClearChildState#2");
                Assert.AreEqual(null, c3.State, "ClearChildState#3");
                Assert.AreEqual(null, c2.Viewstate, "ClearChildState#4");
                Assert.AreEqual(null, c3.Viewstate, "ClearChildState#5");
            }
        }
Beispiel #3
0
        public void LoadViewStateByID()
        {
            ControlWithState c1 = new ControlWithState();
            ControlWithState c2 = new ControlWithState();

            c1.Controls.Add(c2);
            Assert.AreEqual(false, c1.LoadViewStateByID, "LoadViewStateByID#1");
        }
Beispiel #4
0
        public static void ControlState2_Load(Page p)
        {
            ControlWithState parent = new ControlWithState();

            p.Form.Controls.Add(parent);
            if (!p.IsPostBack)
            {
                // emulate DataBind
                parent.Controls.Clear();
                parent.ClearChildControlState();
                ControlWithState c1 = new ControlWithState();
                ControlWithState c2 = new ControlWithState();
                parent.Controls.Add(c1);
                parent.Controls.Add(c2);
                c1.State     = "State1_1";
                c2.State     = "State1_2";
                parent.State = "First";
            }
            else if (parent.State == "First")
            {
                // emulate DataBind
                parent.Controls.Clear();
                parent.ClearChildControlState();
                ControlWithState c1 = new ControlWithState();
                ControlWithState c2 = new ControlWithState();
                parent.Controls.Add(c1);
                parent.Controls.Add(c2);
                c1.State     = "State2_1";
                c2.State     = "State2_2";
                parent.State = "Second";
            }
            else
            {
                // emulate CrerateChildControl only
                parent.Controls.Clear();
                ControlWithState c1 = new ControlWithState();
                ControlWithState c2 = new ControlWithState();
                parent.Controls.Add(c1);
                parent.Controls.Add(c2);

                Assert.AreEqual("State2_1", c1.State, "ControlState#1");
                Assert.AreEqual("State2_2", c2.State, "ControlState#2");
            }
        }
Beispiel #5
0
        public static void ControlState_Load(Page p)
        {
            ControlWithState c1 = new ControlWithState();
            ControlWithState c2 = new ControlWithState();

            c1.Controls.Add(c2);
            p.Form.Controls.Add(c1);
            if (!p.IsPostBack)
            {
                c1.State = "State";
                c2.State = "Cool";
            }
            else
            {
                ControlWithState c3 = new ControlWithState();
                p.Form.Controls.Add(c3);
                Assert.AreEqual("State", c1.State, "ControlState");
                Assert.AreEqual("Cool", c2.State, "ControlState");
            }
        }
Beispiel #6
0
		public void LoadViewStateByID ()
		{
			ControlWithState c1 = new ControlWithState ();
			ControlWithState c2 = new ControlWithState ();
			c1.Controls.Add (c2);
			Assert.AreEqual (false, c1.LoadViewStateByID, "LoadViewStateByID#1");
		}
Beispiel #7
0
		public static void IsChildControlStateCleared_Load (Page p)
		{
			ControlWithState c1 = new ControlWithState ();
			p.Form.Controls.Add (c1);
			if (p.IsPostBack) {
				Assert.IsFalse (c1.IsChildControlStateCleared, "ControlState#1");
				c1.ClearChildControlState ();
				Assert.IsTrue (c1.IsChildControlStateCleared, "ControlState#1");
			}
			ControlWithState c2 = new ControlWithState ();
			c1.Controls.Add (c2);
			ControlWithState c3 = new ControlWithState ();
			c2.Controls.Add (c3);
			if (p.IsPostBack) {
				Assert.IsFalse (c2.IsChildControlStateCleared, "ControlState#1");
				Assert.IsFalse (c3.IsChildControlStateCleared, "ControlState#1");
			}
			if (!p.IsPostBack) {
				c1.State = "State";
				c2.State = "Cool";
				c3.State = "SubCool";
			}
		}
Beispiel #8
0
		public static void ControlState2_Load (Page p) {
			ControlWithState parent = new ControlWithState ();
			p.Form.Controls.Add (parent);
			if (!p.IsPostBack) {
				// emulate DataBind
				parent.Controls.Clear ();
				parent.ClearChildControlState ();
				ControlWithState c1 = new ControlWithState ();
				ControlWithState c2 = new ControlWithState ();
				parent.Controls.Add (c1);
				parent.Controls.Add (c2);
				c1.State = "State1_1";
				c2.State = "State1_2";
				parent.State = "First";
			}
			else if (parent.State == "First") {
				// emulate DataBind
				parent.Controls.Clear ();
				parent.ClearChildControlState ();
				ControlWithState c1 = new ControlWithState ();
				ControlWithState c2 = new ControlWithState ();
				parent.Controls.Add (c1);
				parent.Controls.Add (c2);
				c1.State = "State2_1";
				c2.State = "State2_2";
				parent.State = "Second";
			}
			else {
				// emulate CrerateChildControl only
				parent.Controls.Clear ();
				ControlWithState c1 = new ControlWithState ();
				ControlWithState c2 = new ControlWithState ();
				parent.Controls.Add (c1);
				parent.Controls.Add (c2);

				Assert.AreEqual ("State2_1", c1.State, "ControlState#1");
				Assert.AreEqual ("State2_2", c2.State, "ControlState#2");
			}
		}
Beispiel #9
0
		public static void ControlState_Load (Page p)
		{
			ControlWithState c1 = new ControlWithState ();
			ControlWithState c2 = new ControlWithState ();
			c1.Controls.Add (c2);
			p.Form.Controls.Add (c1);
			if (!p.IsPostBack) {
				c1.State = "State";
				c2.State = "Cool";
			}
			else {
				ControlWithState c3 = new ControlWithState ();
				p.Form.Controls.Add (c3);
				Assert.AreEqual ("State", c1.State, "ControlState");
				Assert.AreEqual ("Cool", c2.State, "ControlState");
			}
		}
Beispiel #10
0
		public static void ClearChildState_Load (Page p)
		{
			ControlWithState c1 = new ControlWithState ();
			p.Form.Controls.Add (c1);
			if (p.IsPostBack) {
				c1.ClearChildState ();
			}
			ControlWithState c2 = new ControlWithState ();
			c1.Controls.Add (c2);
			ControlWithState c3 = new ControlWithState ();
			c2.Controls.Add (c3);
			if (!p.IsPostBack) {
				c1.State = "State";
				c2.State = "Cool";
				c2.Viewstate = "Very Cool";
				c3.State = "SubCool";
				c3.Viewstate = "Super Cool";
			}
			else {
				Assert.AreEqual ("State", c1.State, "ClearChildState#1");
				Assert.AreEqual (null, c2.State, "ClearChildState#2");
				Assert.AreEqual (null, c3.State, "ClearChildState#3");
				Assert.AreEqual (null, c2.Viewstate, "ClearChildState#4");
				Assert.AreEqual (null, c3.Viewstate, "ClearChildState#5");
			}
		}