Author: igorz
Date: 2007-05-07 04:49:07 -0400 (Mon, 07 May 2007)
New Revision: 76809
Modified:
trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/MenuTest.cs
Log:
2007-05-07 Igor Zelmanovich <[EMAIL PROTECTED]>
* MenuItem.cs: fixed:
when 'Value' property is not set, value of 'Text' property is used
instead and vice versa.
* MenuTest.cs:
new tests were added.
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-05-07 08:30:09 UTC (rev 76808)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
2007-05-07 08:49:07 UTC (rev 76809)
@@ -1,3 +1,9 @@
+2007-05-07 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * MenuItem.cs: fixed:
+ when 'Value' property is not set, value of 'Text' property is used
+ instead and vice versa.
+
2007-05-06 Igor Zelmanovich <[EMAIL PROTECTED]>
* TreeNode.cs: fixed:
Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs
2007-05-07 08:30:09 UTC (rev 76808)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/MenuItem.cs
2007-05-07 08:49:07 UTC (rev 76809)
@@ -218,7 +218,12 @@
[DefaultValue ("")]
public string Text {
get {
- return ViewState ["Text"] == null ?
String.Empty : (String) ViewState ["Text"];
+ object o = ViewState ["Text"];
+ if (o == null)
+ o = ViewState ["Value"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
}
set {
ViewState ["Text"] = value;
@@ -240,7 +245,12 @@
[DefaultValue ("")]
public string Value {
get {
- return ViewState ["Value"] == null ?
String.Empty : (String) ViewState ["Value"];
+ object o = ViewState ["Value"];
+ if (o == null)
+ o = ViewState ["Text"];
+ if (o != null)
+ return (string) o;
+ return String.Empty;
}
set {
ViewState ["Value"] = value;
@@ -502,38 +512,36 @@
ToolTip = bin.ToolTip;
// Bind Value property
-
+ string value = null;
if (bin.ValueField.Length > 0) {
- Value = Convert.ToString
(GetBoundPropertyValue (bin.ValueField));
- if (Value.Length == 0)
- Value = bin.Value;
- if (Value.Length == 0)
- Value = bin.Text;
+ value = Convert.ToString
(GetBoundPropertyValue (bin.ValueField));
}
- else if (bin.Value.Length > 0)
- Value = bin.Value;
- else if (bin.Text.Length > 0)
- Value = bin.Text;
- else
- Value = GetDefaultBoundText ();
-
+ if (String.IsNullOrEmpty (value)) {
+ if (bin.Value.Length > 0)
+ value = bin.Value;
+ else if (bin.Text.Length > 0)
+ value = bin.Text;
+ else
+ value = String.Empty;
+ }
+ Value = value;
+
// Bind Text property
-
+ string text = null;
if (bin.TextField.Length > 0) {
- Text = Convert.ToString
(GetBoundPropertyValue (bin.TextField));
+ text = Convert.ToString
(GetBoundPropertyValue (bin.TextField));
if (bin.FormatString.Length > 0)
- Text = string.Format
(bin.FormatString, Text);
- if (Text.Length == 0)
- Text = bin.Text;
- if (Text.Length == 0)
- Text = bin.Value;
+ text = string.Format
(bin.FormatString, text);
}
- else if (bin.Text.Length > 0)
- Text = bin.Text;
- else if (bin.Value.Length > 0)
- Text = bin.Value;
- else
- Text = GetDefaultBoundText ();
+ if (String.IsNullOrEmpty (text)) {
+ if (bin.Text.Length > 0)
+ text = bin.Text;
+ else if (bin.Value.Length > 0)
+ text = bin.Value;
+ else
+ text = String.Empty;
+ }
+ Text = text;
}
else {
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2007-05-07 08:30:09 UTC (rev 76808)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/ChangeLog
2007-05-07 08:49:07 UTC (rev 76809)
@@ -1,3 +1,8 @@
+2007-05-07 Igor Zelmanovich <[EMAIL PROTECTED]>
+
+ * MenuTest.cs:
+ new tests were added.
+
2007-05-06 Igor Zelmanovich <[EMAIL PROTECTED]>
* TreeNodeTest.cs:
Modified: trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/MenuTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/MenuTest.cs
2007-05-07 08:30:09 UTC (rev 76808)
+++ trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/MenuTest.cs
2007-05-07 08:49:07 UTC (rev 76809)
@@ -1544,6 +1544,30 @@
m.Items [0].ChildItems.Add (new MenuItem ());
m.Items [0].ChildItems [0].ChildItems.Add (new MenuItem
());
}
+
+ [Test]
+ public void MenuItem_TextValue1 ()
+ {
+ MenuItem item = new MenuItem ();
+ item.Text = "TTT";
+ Assert.AreEqual ("TTT", item.Value,
"MenuItem_TextValue1#1");
+ item.Value = "";
+ Assert.AreEqual ("", item.Value,
"MenuItem_TextValue1#2");
+ item.Value = null;
+ Assert.AreEqual ("TTT", item.Value,
"MenuItem_TextValue1#3");
+ }
+
+ [Test]
+ public void MenuItem_TextValue2 ()
+ {
+ MenuItem item = new MenuItem ();
+ item.Value = "VVV";
+ Assert.AreEqual ("VVV", item.Text,
"MenuItem_TextValue2#1");
+ item.Text = "";
+ Assert.AreEqual ("", item.Text,
"MenuItem_TextValue2#2");
+ item.Text = null;
+ Assert.AreEqual ("VVV", item.Text,
"MenuItem_TextValue2#3");
+ }
}
}
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches