Forráskód Böngészése

svn path=/trunk/mcs/; revision=73496

Igor Zelmanovich 19 éve
szülő
commit
df60a8c6ea

+ 6 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,9 @@
+2007-02-27 Igor Zelmanovich <[email protected]>
+
+	* TreeNode.cs:
+	* TreeView.cs:
+	fixed LoadPostData to restore checked state for node's checkboxes. 
+
 2007-02-27 Igor Zelmanovich <[email protected]>
 
 	* TreeNodeCollection.cs: 'dirty' flag is assigned if 'marked' only 

+ 12 - 0
mcs/class/System.Web/System.Web.UI.WebControls/TreeNode.cs

@@ -286,6 +286,18 @@ namespace System.Web.UI.WebControls
 				ViewState ["ShowCheckBox"] = value;
 			}
 		}
+
+		internal bool ShowCheckBoxInternal {
+			get {
+				if (ShowCheckBox.HasValue)
+					return ShowCheckBox.Value;
+				else
+					return (Tree.ShowCheckBoxes == TreeNodeTypes.All) ||
+						 ((Tree.ShowCheckBoxes & TreeNodeTypes.Leaf) > 0 && IsLeafNode) ||
+						 ((Tree.ShowCheckBoxes & TreeNodeTypes.Parent) > 0 && IsParentNode && Parent != null) ||
+						 ((Tree.ShowCheckBoxes & TreeNodeTypes.Root) > 0 && Parent == null && ChildNodes.Count > 0);
+			}
+		}
 		
 		[DefaultValue ("")]
 		public string Target {

+ 13 - 22
mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs

@@ -1016,11 +1016,8 @@ namespace System.Web.UI.WebControls
 				res = true;
 			}
 
-			if (ShowCheckBoxes != TreeNodeTypes.None) {
-				UnsetCheckStates (Nodes, postCollection);
-				SetCheckStates (postCollection);
-				res = true;
-			}
+			UnsetCheckStates (Nodes, postCollection);
+			SetCheckStates (postCollection);
 			
 			if (EnableClientScript) {
 				string states = postCollection [ClientID + "_ExpandStates"];
@@ -1409,16 +1406,7 @@ namespace System.Web.UI.WebControls
 			
 			// Checkbox
 			
-			bool showChecks;
-			if (node.ShowCheckBox.HasValue)
-				showChecks = node.ShowCheckBox.Value;
-			else
-				showChecks = (ShowCheckBoxes == TreeNodeTypes.All) ||
-							 ((ShowCheckBoxes & TreeNodeTypes.Leaf) > 0 && node.IsLeafNode) ||
-							 ((ShowCheckBoxes & TreeNodeTypes.Parent) > 0 && node.IsParentNode && node.Parent != null) ||
-							 ((ShowCheckBoxes & TreeNodeTypes.Root) > 0 && node.Parent == null && node.ChildNodes.Count > 0);
-
-			if (showChecks) {
+			if (node.ShowCheckBoxInternal) {
 				writer.AddAttribute ("name", ClientID + "_cs_" + node.Path);
 				writer.AddAttribute ("type", "checkbox");
 				writer.AddAttribute ("title", node.Text);
@@ -1779,10 +1767,10 @@ namespace System.Web.UI.WebControls
 		
 		void UnsetCheckStates (TreeNodeCollection col, NameValueCollection states)
 		{
-			foreach (TreeNode node in col) {
-				if (node.Checked) {
-					string val = states [ClientID + "_cs_" + node.Path];
-					if (val != "on") node.Checked = false;
+			foreach (TreeNode node in col) {
+				if (node.ShowCheckBoxInternal && node.Checked) {
+					if (states == null || states [ClientID + "_cs_" + node.Path] == null)
+						node.Checked = false;
 				}
 				if (node.HasChildData)
 					UnsetCheckStates (node.ChildNodes, states);
@@ -1790,14 +1778,17 @@ namespace System.Web.UI.WebControls
 		}
 		
 		void SetCheckStates (NameValueCollection states)
-		{
+		{
+			if (states == null)
+				return;
+
 			string keyPrefix = ClientID + "_cs_";
 			foreach (string key in states) {
 				if (key.StartsWith (keyPrefix)) {
 					string id = key.Substring (keyPrefix.Length);
 					TreeNode node = FindNodeByPos (id);
-					if (node != null)
-						node.Checked = (Context.Request.Form [key] == "on");
+					if (node != null && !node.Checked)
+						node.Checked = true;
 				}
 			}
 		}

+ 0 - 1
mcs/class/System.Web/Test/System.Web.UI.WebControls/TreeViewTest.cs

@@ -1866,7 +1866,6 @@ namespace MonoTests.System.Web.UI.WebControls {
 
 		[Test]
 		[Category ("NunitWeb")]
-		[Category ("NotWorking")] // Implementation details for mono  
 		public void TreeView_PostBackFireEvents_2 ()
 		{
 			WebTest t = new WebTest ("NoEventValidation.aspx");