Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Custom Condition and NotificationSettings Text
posted

Hello,

I have to validate a control against multiple different conditions. I have created a Custom Condition class and put my conditions in the Matches subroutine.

What I'd like to do is to customize also the Notification settings text that appears when one of the conditions is not matched. I can do this by passing the Control object and Validator object in the constructor of my class. The problem is that the Matches subroutine is not raised when the control value is empty, and so I can't customize the message in the "isRequired" condition is True.

To be more specific:

If the condition 1 is false, notification text has to be "Condition 1 not satisfied"

If the condition 2 is false, notification text has to be "Condition 2 not satisfied"

If the value is empty (and isRequired is true), notification text has to be "Value mandatory"

I'm not able to do the last one because Matches event is not raised when leaving the control with value empty, so notification text remains the older one (for example "Condition 2 not satisfied").

Parents
  • 21795
    Offline posted

    Hello Claudio,

    You are on the right way. After implementing the ICondition interface you need set different rules in Matches method. In this method you should implements your conditions, based on which validation is considered as valid or not.   For each condition which doesn’t matches you can add error message in a combined error message. Finally you can set this error message overriding the ToString method of your Condition class.

    In your Form Load you have to implement your custom Condition class in new ValidationSettings and apply it to your control. Here you may set IsRequired property to true and custom NotificationSettings text.

    Please find attached a sample solution implementing above mentioned logic.

    Please let me know if this is what you are looking for or if I am missing something.

    Sincerely,

    Milko

    Developer Support Engineer

    Infragistics, Inc.

    www.infragistics.com/support

    CAS-143551-N9K5W9.zip
Reply Children