mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 03:51:19 -10:00
* 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
93 lines
1.7 KiB
C#
93 lines
1.7 KiB
C#
/**
|
|
* Namespace: System.Web.UI.WebControls
|
|
* Class: CompareValidator
|
|
*
|
|
* Author: Gaurav Vaish
|
|
* Maintainer: [email protected]
|
|
* Implementation: yes
|
|
* Status: 80%
|
|
*
|
|
* (C) Gaurav Vaish (2001)
|
|
*/
|
|
|
|
using System;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
|
|
namespace System.Web.UI.WebControls
|
|
{
|
|
[ToolboxData("<{0}:CompareValidator runat=\"server\""
|
|
+ "ErrorMessage=\"CompareValidator\"></{0}:CompareValidator>")]
|
|
public class CompareValidator: BaseCompareValidator
|
|
{
|
|
public CompareValidator()
|
|
{
|
|
// Intitalize();
|
|
}
|
|
|
|
public string ControlToCompare
|
|
{
|
|
get
|
|
{
|
|
object o = ViewState["ControlToCompare"];
|
|
if(o!=null)
|
|
return (string)o;
|
|
return String.Empty;
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["ControlToCompare"] = value;
|
|
}
|
|
}
|
|
|
|
public ValidationCompareOperator Operator
|
|
{
|
|
get
|
|
{
|
|
object o = ViewState["Operator"];
|
|
if(o!=null)
|
|
return (ValidationCompareOperator)o;
|
|
return ValidationCompareOperator.Equal;
|
|
}
|
|
set
|
|
{
|
|
if(!System.Enum.IsDefined(typeof(ValidationCompareOperator), value))
|
|
throw new ArgumentException();
|
|
ViewState["Operator"] = value;
|
|
}
|
|
}
|
|
|
|
public string ValueToCompare
|
|
{
|
|
get
|
|
{
|
|
object o = ViewState["ValueToCompare"];
|
|
if(o!=null)
|
|
return (string)o;
|
|
return String.Empty;
|
|
}
|
|
set
|
|
{
|
|
ViewState["ValueToCompare"] = value;
|
|
}
|
|
}
|
|
|
|
protected override bool EvaluateIsValid ()
|
|
{
|
|
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 Compare (ctrl, cmp, Operator, Type);
|
|
}
|
|
}
|
|
}
|