Validation Error Message: Raise by code

3 posts, 0 answers
  1. Michael Hilgers
    Michael Hilgers avatar
    76 posts
    Member since:
    Apr 2010

    Posted 18 Oct 2013 Link to this post

    Hello everyone,

    i'm using a MaskedTextInput field with validation. When the user enters the field and types a "wrong" text (in this case empty text is not allowed), the validation error is shown like expected (field get's the red border an the red tooltip with error message is shown).

    But it's likely, that the user doesn't edit this required field and so no validation error can raise (an empty field is a validation error). In this case, i want to raise this validation error manually by code when the user want's so save the form.

    How can i do this? I can't find any methods to display the validation error manually.

    Regards,
    Michael
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Oct 2013 Link to this post

    Hi Michael,

     Have you considered using IDataErorInfo interface for a validation mechanism ? It's validation code will be triggered early (when the binding is initially evaluated) and the control will be loaded with red border. This will notify the user that this field is requried. 
    On the other hand vfalidating with DataAnnotations is not so suitable because the Validation Exception will be fired before the MaskedInput has loaded and this will break the application.
    Let us know what you think of the approach with IDataErrorInfo.
    On a side note, you can take a look at this great article for Validation in .Net.

    Regards,
    Petar Mladenov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Michael Hilgers
    Michael Hilgers avatar
    76 posts
    Member since:
    Apr 2010

    Posted 23 Oct 2013 Link to this post

    Hello Peter,

    thanks, IDataErorInfo is what I was looking for!

    Regards,
    Michael
Back to Top