I am using the Validationprovider control for the 1st time. I've had limited success trying to mimic the functionality t hat I saw in the ValidationQuickStart solution example that comes with the Ent Lib installation.
While I was able to get form errorprovider icons to appear based on Business Object validations that decorate the BO property with validation attribute such as:
<NotNullValidator(MessageTemplate:="Gender must be specified.", RuleSet:="MyRule", Tag:="Gender")> _
Public Shadows Property Gender() As String
Get
Return MyBase.Gender
End Get
Set(ByVal value As String)
MyBase.Gender = value
End Set
End Property
However, if I wanted to add an edit to the "SelfValidation" method, how would I tie the Result to a form control?
(In Self Validation)
If Me.Attornet s Nothing Then
Dim result As New ValidationResult("Attorney selection is required", Me, Nothing, Nothing, Nothing)
results.AddResult(result)
End If
Or must I create by own **CUSTOM VALIDATOR?" and then use its type to decorate a Business Object property?
Edit:
If The ValidationProvider control is not intended for cross-control validation like this one:
if the user selects the "Yes" option in the radio button group corresponding to Business Option property Customer.DoYouSmokeCrack As Boolean then the txtHowMuch control should be flagged with an ErrorProvider icon indicating that this field is conditionally required.
The way I am doing this now is to do this in a Self Validation block and, when I add a ValidationResult object to the collection, I set the Key property to "Explanation" so the GUI can use it to manually map to the offending screen control.
Is there a more standard/beter way to do this?