2 * Namespace: System.Web.UI.WebControls
\r
3 * Class: BaseValidator
\r
5 * Author: Gaurav Vaish
\r
6 * Maintainer: gvaish@iitk.ac.in
\r
7 * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>
\r
10 * (C) Gaurav Vaish (2001)
\r
14 using System.ComponentModel;
\r
16 using System.Web.UI;
\r
17 using System.Drawing;
\r
19 namespace System.Web.UI.WebControls
\r
21 public abstract class BaseValidator: Label, IValidator
\r
24 private PropertyDescriptor pDesc;
\r
25 private string ctValid = String.Empty;
\r
26 private ValidatorDisplay vDisp = ValidatorDisplay.Static;
\r
27 private bool enableClientScript; //TODO: check the default value := false;
\r
28 private bool enabled = true;
\r
29 private string errorMessage = String.Empty;
\r
30 private Color foreColor = Color.Red;
\r
31 private bool isValid = true;
\r
32 private bool propertiesValid;
\r
33 private bool renderUplevel;
\r
35 public static PropertyDescriptor GetValidationProperty(object component)
\r
37 //TODO: Have to workout this one!
\r
41 public string ControlToValidate
\r
53 public ValidatorDisplay Display
\r
61 //TODO: Throw new exception ArgumentException("....") if the value is not valid
\r
66 public bool EnableClientScript
\r
70 return enableClientScript;
\r
74 enableClientScript = value;
\r
78 public override bool Enabled
\r
90 public string ErrorMessage
\r
94 return errorMessage;
\r
98 errorMessage = value;
\r
102 public override Color ForeColor
\r
114 public bool IsValid
\r
126 public void Validate()
\r
128 // TODO: write the validation code
\r
129 // TODO: update the value of isValid
\r
132 protected BaseValidator()
\r
134 // Dummy Constructor
\r
137 protected bool PropertiesValid
\r
141 // TODO: throw HttpException, but when? How do I know about all the controls?
\r
142 return propertiesValid;
\r
146 protected bool RenderUplevel
\r
150 //TODO: To set the value of renderUplevel. Problem: when, how?
\r
151 return renderUplevel;
\r
155 protected void CheckControlValidationProperty(string name, string propertyName)
\r
157 //TODO: I think it needs to be overridden. I may be wrong!
\r
158 //TODO: When to throw HttpException(...)
\r
161 protected virtual bool ControlPropertiesValid()
\r
163 // Do I need to do anything? But what?
\r
164 // What do I do with ControlToValidate?
\r
168 protected virtual bool DetermineRenderUplevel()
\r
174 protected abstract bool EvaluateIsValid();
\r
176 protected string GetControlRenderID(string name)
\r
178 // TODO: What value? What is it?
\r
181 protected string GetControlValidationValue(string name)
\r
183 // TODO: What value? What is it?
\r
186 protected void RegisterValidatorCommonScript()
\r
188 // TODO: Still wondering!
\r
189 // Note: This method is primarily used by control developers
\r
192 protected void RegisterValidatorDeclaration()
\r
194 // TODO: Still wondering!
\r
195 // Note: This method is primarily used by control developers
\r
196 // The documentation in M$ refers to: Page_Validators array
\r