From 9096fdf8c06d03c72203f4cecab27322b31aace0 Mon Sep 17 00:00:00 2001 From: Gonzalo Paniagua Javier Date: Tue, 17 Dec 2002 07:31:20 +0000 Subject: [PATCH] 2002-12-17 Gonzalo Paniagua Javier * 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 --- .../BaseValidator.cs | 14 ++++++----- .../System.Web.UI.WebControls/ChangeLog | 9 +++++++ .../CompareValidator.cs | 21 +++++++++------- .../RegularExpressionValidator.cs | 25 ++++++++----------- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs index cd70de8a508..76db43afad9 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs @@ -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; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 0e786cfb90c..a55e3450bcf 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,12 @@ +2002-12-17 Gonzalo Paniagua Javier + + * 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 * Xml.cs: use MapPathSecure to get the path of the document. diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs index 8494f0182ca..c6d19b53fb1 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/CompareValidator.cs @@ -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); } } } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs index 961e45def85..dd2ee91de64 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/RegularExpressionValidator.cs @@ -65,26 +65,21 @@ namespace System.Web.UI.WebControls } } - protected override bool EvaluateIsValid() + protected override bool EvaluateIsValid () { - string ctrl = GetControlValidationValue(ControlToValidate); - bool retVal = true; - if(ctrl == null || ctrl.Trim().Length == 0) - { + string ctrl = GetControlValidationValue (ControlToValidate); + if (ctrl == null || ctrl.Trim ().Length == 0) return true; - } - try - { - Match match = Regex.Match(ctrl, ValidationExpression); - if(match.Success && match.Index > 0 && match.Length == ctrl.Length) - { + + bool retVal; + try { + Match match = Regex.Match (ctrl, ValidationExpression); + if (match.Success && match.Index == 0) { retVal = true; - } else - { + } else { retVal = false; } - } catch(Exception) - { + } catch (Exception) { retVal = true; } return retVal; -- 2.25.1