[ToolboxData("<{0}:CustomValidator runat=server ErrorMessage=\"CustomValidator\"></{0}:CustomValidator>")]
#endif
public class CustomValidator : BaseValidator {
+ static readonly object serverValidateEvent = new object ();
+
+ EventHandlerList events = new EventHandlerList ();
+
+ #region Events
+ [WebSysDescription ("")]
+ [WebCategory ("Behavior")]
+ public event ServerValidateEventHandler ServerValidate {
+ add { events.AddHandler (serverValidateEvent, value); }
+ remove { events.RemoveHandler (serverValidateEvent, value); }
+ }
+
+ #endregion // Events
+
#region Public Constructors
public CustomValidator() {
}
if (base.RenderUplevel) {
string s;
-
- writer.AddAttribute("evaluationfunction", "CustomValidatorEvaluateIsValid");
+
+#if NET_2_0
+ RegisterExpandoAttribute (ClientID, "evaluationfunction", "CustomValidatorEvaluateIsValid");
+ if (ValidateEmptyText)
+ RegisterExpandoAttribute (ClientID, "validateemptytext", "true");
+ s = ClientValidationFunction;
+ if (!String.IsNullOrEmpty (s))
+ RegisterExpandoAttribute (ClientID, "clientvalidationfunction", s, true);
+#else
+ writer.AddAttribute ("evaluationfunction", "CustomValidatorEvaluateIsValid", false);
s = ClientValidationFunction;
- if (s != string.Empty) {
+ if (s != String.Empty)
writer.AddAttribute("clientvalidationfunction", s);
- }
-
-#if NET_2_0
- if (ValidateEmptyText)
- Page.ClientScript.RegisterExpandoAttribute (ClientID, "validateemptytext", "true");
#endif
}
}
}
protected virtual bool OnServerValidate(string value) {
- if (ServerValidate != null) {
+ ServerValidateEventHandler eh = events [serverValidateEvent] as ServerValidateEventHandler;
+ if (eh != null) {
ServerValidateEventArgs e;
e = new ServerValidateEventArgs(value, true);
- ServerValidate(this, e);
+ eh (this, e);
return e.IsValid;
}
return true;
}
#endregion // Public Instance Methods
-
- #region Events
- [WebSysDescription ("")]
- [WebCategory ("Behavior")]
- public event ServerValidateEventHandler ServerValidate;
- #endregion // Events
}
}