Author: kostat
Date: 2007-01-17 11:56:41 -0500 (Wed, 17 Jan 2007)
New Revision: 71209

Modified:
   trunk/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs
   
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/BaseValidatorTest.cs
Log:
ToString the validating property value, if null return an empty string

Modified: trunk/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs       
2007-01-17 16:32:16 UTC (rev 71208)
+++ trunk/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs       
2007-01-17 16:56:41 UTC (rev 71209)
@@ -325,14 +325,7 @@
                                return null;
 
                        object o = prop.GetValue (control);
-                       if (o is string)
-                               return (string)o;
-                       else if (o is ListItem)
-                               return ((ListItem)o).Value;
-                       else {
-                               // XXX
-                               return null;
-                       }
+                       return o != null ? o.ToString () : String.Empty;
                }
 
                public static PropertyDescriptor GetValidationProperty (object 
o)

Modified: 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/BaseValidatorTest.cs
===================================================================
--- 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/BaseValidatorTest.cs  
    2007-01-17 16:32:16 UTC (rev 71208)
+++ 
trunk/mcs/class/System.Web/Test/System.Web.UI.WebControls/BaseValidatorTest.cs  
    2007-01-17 16:56:41 UTC (rev 71209)
@@ -243,6 +243,21 @@
                }
 
                [Test]
+               public void NullValidationProperty ()
+               {
+                       BaseValidatorPoker v = new BaseValidatorPoker ();
+
+                       Page p = new Page ();
+                       p.Controls.Add (v);
+                       RadioButtonList l = new RadioButtonList ();
+                       p.Controls.Add (l);
+                       l.ID = "XXX";
+                       v.ControlToValidate = "XXX";
+
+                       Assert.AreEqual (String.Empty, 
v.DoGetControlValidationValue ("XXX"), "#A1");
+               }
+
+               [Test]
                [ExpectedException (typeof (HttpException))]
                public void ControlPropertiesValid2 ()
                {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to