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"; } }
public static void ClearChildControlState_Load(Page p) { ControlWithState c1 = new ControlWithState(); p.Form.Controls.Add(c1); if (p.IsPostBack) { c1.ClearChildControlState(); } 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"; c3.State = "SubCool"; } else { Assert.AreEqual("State", c1.State, "ControlState#1"); Assert.AreEqual(null, c2.State, "ControlState#2"); Assert.AreEqual(null, c3.State, "ControlState#2"); } }
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"); } }
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"; } }
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"); } }
public static void ClearChildControlState_Load (Page p) { ControlWithState c1 = new ControlWithState (); p.Form.Controls.Add (c1); if (p.IsPostBack) { c1.ClearChildControlState (); } 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"; c3.State = "SubCool"; } else { Assert.AreEqual ("State", c1.State, "ControlState#1"); Assert.AreEqual (null, c2.State, "ControlState#2"); Assert.AreEqual (null, c3.State, "ControlState#2"); } }