Hi
I have an UltraTextEditor and an UltraValidator in a form.
I want to validate that the text in the UltraTextEditor is a path to an existing file (which I do with FileInfo.Exists). However under a certain condition (a specific value in the form) I want to allow the UltraTextEditor.Text to be empty. I can't seem to set up the UltraValidator for this UltraTextEditor so that it only accepts an empty value when this condition is met, and so would like to get help with this. How can I acieve this behavior?
I've tried:
A) Setting IsRequired to True and then, in an UltraValidator.Validating event handler, setting e.IsValid to True when the text is empty but the condition is met. However this doesn't have an effect; the validation fails anyway. It seems that the IsRequired setting causes the UltraValidator to ignore my futile attemts to override the validation when the UltraTextEditor.Text is empty.
B) Setting IsRequired to False and created a custom implementation of ICondition that returns False when the text is empty and the condition is not met. Unfortunately the validation does not fail in this case. It seems that the UltraValidator accepts empty values regardles of what I return from the implementation of ICondition.Matches(...).
Thanks Hristo!
Your sample works just like I wanted.
Being unfamiliar with the UltraValidator and it's possibilities using a custom ICondition implementation, I got stuck in one line of thought and, however obvious it seems in retrospect, didn't think of setting the IsRequired property based on the condition.
Hello,
Based on the description of you issue I’ve implemented simple sample that uses ICondition in order to validate UltraTextBox. Please run the sample and let me know if this is the desired result.
Please let me know if you have any further questions.