This is a migrated thread and some comments may be shown as answers.

Validation Error Message: Raise by code

2 Answers 69 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Michael Hilgers
Top achievements
Rank 1
Michael Hilgers asked on 18 Oct 2013, 09:21 AM
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 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Oct 2013, 07:11 AM
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 >>
0
Michael Hilgers
Top achievements
Rank 1
answered on 23 Oct 2013, 11:20 AM
Hello Peter,

thanks, IDataErorInfo is what I was looking for!

Regards,
Michael
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Michael Hilgers
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Michael Hilgers
Top achievements
Rank 1
Share this question
or