| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /**
- * Namespace: System.Web.UI.WebControls
- * Class: BaseValidator
- *
- * Author: Gaurav Vaish
- * Maintainer: [email protected]
- * Contact: <[email protected]>, <[email protected]>
- * Implementation: yes
- * Status: 20%
- *
- * (C) Gaurav Vaish (2001)
- */
- using System;
- using System.ComponentModel;
- using System.Web;
- using System.Web.UI;
- using System.Drawing;
- namespace System.Web.UI.WebControls
- {
- public abstract class BaseValidator: Label, IValidator
- {
- //
- private PropertyDescriptor pDesc;
- private string ctValid = String.Empty;
- private ValidatorDisplay vDisp = ValidatorDisplay.Static;
- private bool enableClientScript; //TODO: check the default value := false;
- private bool enabled = true;
- private string errorMessage = String.Empty;
- private Color foreColor = Color.Red;
- private bool isValid = true;
- private bool propertiesValid;
- private bool renderUplevel;
- public static PropertyDescriptor GetValidationProperty(object component)
- {
- //TODO: Have to workout this one!
- return null;
- }
-
- public string ControlToValidate
- {
- get
- {
- return ctValid;
- }
- set
- {
- ctValid = value;
- }
- }
-
- public ValidatorDisplay Display
- {
- get
- {
- return vDisp;
- }
- set
- {
- //TODO: Throw new exception ArgumentException("....") if the value is not valid
- vDisp = value;
- }
- }
-
- public bool EnableClientScript
- {
- get
- {
- return enableClientScript;
- }
- set
- {
- enableClientScript = value;
- }
- }
-
- public override bool Enabled
- {
- get
- {
- return enabled;
- }
- set
- {
- enabled = value;
- }
- }
-
- public string ErrorMessage
- {
- get
- {
- return errorMessage;
- }
- set
- {
- errorMessage = value;
- }
- }
-
- public override Color ForeColor
- {
- get
- {
- return foreColor;
- }
- set
- {
- foreColor = value;
- }
- }
-
- public bool IsValid
- {
- get
- {
- return isValid;
- }
- set
- {
- isValid = value;
- }
- }
-
- public void Validate()
- {
- // TODO: write the validation code
- // TODO: update the value of isValid
- }
-
- protected BaseValidator()
- {
- // Dummy Constructor
- }
-
- protected bool PropertiesValid
- {
- get
- {
- // TODO: throw HttpException, but when? How do I know about all the controls?
- return propertiesValid;
- }
- }
-
- protected bool RenderUplevel
- {
- get
- {
- //TODO: To set the value of renderUplevel. Problem: when, how?
- return renderUplevel;
- }
- }
-
- protected void CheckControlValidationProperty(string name, string propertyName)
- {
- //TODO: I think it needs to be overridden. I may be wrong!
- //TODO: When to throw HttpException(...)
- }
- protected virtual bool ControlPropertiesValid()
- {
- // Do I need to do anything? But what?
- // What do I do with ControlToValidate?
- return true;
- }
- protected virtual bool DetermineRenderUplevel()
- {
- // From where?
- return true;
- }
- protected abstract bool EvaluateIsValid();
- [MonoTODO]
- protected string GetControlRenderID(string name)
- {
- // TODO: What value? What is it?
- throw new NotImplementedException();
- }
- [MonoTODO]
- protected string GetControlValidationValue(string name)
- {
- throw new NotImplementedException();
- // TODO: What value? What is it?
- }
- [MonoTODO]
- protected void RegisterValidatorCommonScript()
- {
- throw new NotImplementedException();
- // TODO: Still wondering!
- // Note: This method is primarily used by control developers
- }
- [MonoTODO]
- protected void RegisterValidatorDeclaration()
- {
- // TODO: Still wondering!
- // Note: This method is primarily used by control developers
- // The documentation in M$ refers to: Page_Validators array
- throw new NotImplementedException();
- }
- }
- }
|