Issues in VAB need to be solved

Topics: Validation Application Block
Apr 17, 2008 at 2:25 PM
Edited Apr 20, 2008 at 9:55 AM
For a certain business object :

1- I need to validate a controls with no corrospnding property. ( can this be done using VAB, if not can i combine VAB validation with normal validation? and how? )

2- I have properties with validation attributes but I don't want to validate them in all my webforms, but i still need to validate them in other webforms - how can this be done ?
Apr 17, 2008 at 10:36 PM

1. The VAB integrates with the standard ASP.NET validation mechanism, so you should be able to add any other ASP.NET validator you need.

2. I'm not sure what you mean here. If you are using the integration validator, the only properties involved in the validation are the ones for which a proxy validator was configured on a control. Note that this is not the same as validating the property itself. If you're validating one of your business objects after updating its properties with the values from the ASP.NET controls, then you should define rulesets so you can perform partial validations.

Apr 20, 2008 at 9:40 AM
Edited Apr 20, 2008 at 10:35 AM

1. I am using codebehind validation for example :
Validator validator = ValidationFactory.CreateValidator(obj.GetType());
ValidationResults results = validator.Validate(obj);
then i loop through the results to handle them - and i want to combine these results with the standard ASP.NET validation results to have the same handling.

2. I think rulesets is a good solution, thx.

Apr 21, 2008 at 1:28 PM

To have proper integration with ASP.NET's validation you need a validator control. Otherwise your validation will happen either before controls' values have been validated (if you fire your validation before the validation step in the page's lifecycle), or not at all until all other controls' values are valid (because the validation step will not let you continue if these controls' values are not valid).

Is there a reason why the PropertyProxyValidator won't work for you and you need to fire a full blown validation in your codebehind? The proxy validator will only attempt to validate the property for which it has been configured, and it will integrate with ASP.NET's validation.