Hi -
I've been playing with the WinValidator in a test app; one scenario that is causing me issues which is baflling to me is this:
I have a texteditor associated to a validator - IsRequired. Very simple. I'm also handling the ValidationError event with a switch just like in the docs. That ALL works fine. However, when I call the Validate() method in my Save button click, the ValidationError event fires, but then fails on an invalid object reference to the e.Control.Name in the switch. Note: this event runs fine if fired by the control itself.
How would you then handle the ValidationError event, yet STILL be able to explicity call Validate just prior to saving a form??
leighkendall said:In the UltraValidator, what would be the equivalent of ASP.NET's CustomValidator & RegularExpressionValidator?
ICondition would appear to answer this question; unless you have something else to suggest... thanks again.
Yes, I saw ICondition in the class docs - I'll play with that thanks!
Please see my code below: Note the If statement checking the IsSingleEntityValidation; that was the only way I could get the Validate method to execute, however, now the Switch statement doesn't run during a call to Validate(). Is this the proper way to do this? The ValidationError code runs fine when it's fired by a single control, but when it runs as a result of me calling the Validate method, yes it fails on a NullRef to the e.Control. This doesn't seem intuitive at all to me. What's the proper way to handle or set the ValidationSettings during the ValidationError event, yet be able to call Validate from a Save button without getting the NullRef error??
-----------------------------------------
Private Sub UltraValidator1_ValidationError(ByVal sender As System.Object, ByVal e As Infragistics.Win.Misc.ValidationErrorEventArgs) Handles UltraValidator1.ValidationError
If Not e.IsSingleEntityValidation Then Return End If
Select Case e.Control.Name
Case Me.LastNameTextBox.Name e.NotificationSettings.Action = Infragistics.Win.Misc.NotificationAction.Image e.NotificationSettings.Text = "This is a custom message"
End Select
End Sub
>> for more complex validation scenarios, such as those defined by the business logic layer, a custom implementation of the ICondition interface can be assigned. <<
Or is that the way to do it? Custom validation code that is. It seems the UltraValidator is very similar to the ASP.NET validators, so I'm trying to equate the IG one's to ASP.NET's.
In the UltraValidator, what would be the equivalent of ASP.NET's CustomValidator & RegularExpressionValidator?
leighkendall said:However, when I call the Validate() method in my Save button click, the ValidationError event fires, but then fails on an invalid object reference to the e.Control.Name in the switch
leighkendall said:what's the best way to do custom code validation and still tap into using the validator and it's notificationsettings for showing and icon/tooltip etc?