I have a standard ASP.NET (WebForms, not MVC) custom validator assigned to a TextBox. I want the TextBox event OnBlur (or OnChange) to trigger the client-side validation function specified by the Customer Control. Way back in .Net 1.1 I could call “ValidatorHookupControl” to wire this up “OnLoad” but that is apparently no longer part of the infrastructure, so how does one accomplish this?
I am guessing its something obvious, but so far it escape me, and too many hours have passed going in circles… any help appreciated.
Note: I want to stay within the .Net Validation structure so that “onBlur” validation errors are reported in the same place / format (aka Validation Summary) as the other Validators that are fired at submit time.
You don’t need a custom validator, even
CustomValidator.ClientValidationFunction.If you want to use ASP.NET validation infrastructure, inherit from BaseValidator and subscribe using JavaScript (I recommend to use jQuery) to target control’s event you need. And the perform the validation.
Or you can use
CustomValidator.ClientValidationFunction. Inherit from CustomValidator, on (probably)Control.PreInit()subscribe validator’s function to target control’s event you need, and wait the function to be called.