2002-12-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 17 Dec 2002 07:31:20 +0000 (07:31 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 17 Dec 2002 07:31:20 +0000 (07:31 -0000)
* BaseValidator.cs: return an empty string in GetControlValidationValue
when GetValue returned null.

* CompareValidator.cs: fixed EvaluateIsValid.

* RegularExpressionValidator.cs: fixed EvaluateIsValid.

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

mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs
mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs

index cd70de8a508633551a514a9be089fb87f595df9e..76db43afad94bfb0c22f45bbb9377e89d0dc1ab4 100755 (executable)
@@ -307,12 +307,14 @@ namespace System.Web.UI.WebControls
                                PropertyDescriptor pd = GetValidationProperty(ctrl);
                                if(pd != null)
                                {
-                                       object item = pd.GetValue(ctrl);
-                                       if(item is ListItem)
-                                       {
-                                               return ((ListItem)item).Value;
-                                       }
-                                       return item.ToString();
+                                       object item = pd.GetValue (ctrl);
+                                       if (item is ListItem)
+                                               return ((ListItem) item).Value;
+
+                                       if (item == null)
+                                               return String.Empty;
+
+                                       return item.ToString ();
                                }
                        }
                        return null;
index 0e786cfb90cab7002fdbf77041f4f4f46b9920b1..a55e3450bcf89c012ae1421956236f150a346850 100644 (file)
@@ -1,3 +1,12 @@
+2002-12-17  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * BaseValidator.cs: return an empty string in GetControlValidationValue
+       when GetValue returned null.
+
+       * CompareValidator.cs: fixed EvaluateIsValid.
+
+       * RegularExpressionValidator.cs: fixed EvaluateIsValid.
+
 2002-12-17  Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * Xml.cs: use MapPathSecure to get the path of the document.
index 8494f0182ca73b6db603b01bf59af06d2a3066b9..c6d19b53fb1ed00037444e4eb2ca3f526fbc213d 100644 (file)
@@ -73,17 +73,20 @@ namespace System.Web.UI.WebControls
                        }
                }
 
-               protected override bool EvaluateIsValid()
+               protected override bool EvaluateIsValid ()
                {
-                       string ctrl = GetControlValidationValue(ControlToValidate);
-                       if(ctrl != null && ctrl.Length > 0)
-                       {
-                               string cmp = (ControlToCompare.Length > 0 ?
-                                             ControlToCompare : ValueToCompare);
-                               return BaseCompareValidator.Compare(ctrl, cmp,
-                                                                   Operator, Type);
+                       string ctrl = GetControlValidationValue (ControlToValidate);
+                       if (ctrl == null || ctrl.Length == 0)
+                               return true;
+
+                       string cmp;
+                       if (ControlToCompare.Length > 0) {
+                               cmp = GetControlValidationValue (ControlToCompare);
+                       } else {
+                               cmp = ValueToCompare;
                        }
-                       return true;
+
+                       return Compare (ctrl, cmp, Operator, Type);
                }
        }
 }
index 961e45def85a4d80b47904915db732d240fc6a37..dd2ee91de64b978ac552aebd26e4cc45139c7e1c 100644 (file)
@@ -65,26 +65,21 @@ namespace System.Web.UI.WebControls
                        }\r
                }\r
 \r
-               protected override bool EvaluateIsValid()\r
+               protected override bool EvaluateIsValid ()\r
                {\r
-                       string ctrl = GetControlValidationValue(ControlToValidate);\r
-                       bool   retVal = true;\r
-                       if(ctrl == null || ctrl.Trim().Length == 0)\r
-                       {\r
+                       string ctrl = GetControlValidationValue (ControlToValidate);\r
+                       if (ctrl == null || ctrl.Trim ().Length == 0)\r
                                return true;\r
-                       }\r
-                       try\r
-                       {\r
-                               Match match = Regex.Match(ctrl, ValidationExpression);\r
-                               if(match.Success && match.Index > 0 && match.Length == ctrl.Length)\r
-                               {\r
+\r
+                       bool retVal;\r
+                       try {\r
+                               Match match = Regex.Match (ctrl, ValidationExpression);\r
+                               if (match.Success && match.Index == 0) {\r
                                        retVal = true;\r
-                               } else\r
-                               {\r
+                               } else {\r
                                        retVal = false;\r
                                }\r
-                       } catch(Exception)\r
-                       {\r
+                       } catch (Exception) {\r
                                retVal = true;\r
                        }\r
                        return retVal;\r