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

RadMaskedNumericInput and Validation

7 Answers 242 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Masoud
Top achievements
Rank 1
Masoud asked on 10 Oct 2012, 03:58 PM
Hi there,

Here are the components I use
Telerik Controls 2012Q2 (2012.1.430.1050).  
WCF RIA and especially the validation system.

I have a property on model that is decorated with a custom Validation as in 
[System.ComponentModel.DataAnnotations.CustomValidationAttribute(typeof(Wk.Data.BasisBaumEntityValidator), @"ValidateRechtswert")]

Following is the xaml of the MaskedInput
<RadInput:RadMaskedNumericInput Name="X" Mask="#6.2" Value="{Binding Path=Current.X, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnNotifyDataErrors=True, ValidatesOnDataErrors=True}" Width="110" MaskedInput:MaskedInputExtensions.Minimum="0" IsReadOnly="{Binding Path=IsReadOnly}" />

The validation is hit twice:
  • - when the value of the property is changed
  • - before WCF RIA issues a submit operation

When the user changes the value while editing the entity, the validation is done and an error is displayed as you can see in maskedinput_witherrormessage.png

When the entity is submitted via WCF RIA, the validation is performed and ValidationErrors collection is properly filled.  However, the error message is not displayed property.  Please see maskedinput_noerrormessage.png.  The little red dot on the right of the control is where the error message is usually displayed. 

How can I further investigate this issue?

Thank you for your help!





7 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 15 Oct 2012, 10:12 AM
Hello Klaus,

 Could you please first test this with our latest official binaries (Q2 2012 SP2 0912) ? I noticed you use Q2 2012 but the numbers in the brackets indicate internal build from April 30th (2012.1.430.1050).
 As I managed to understand, the first and second validation types a different - first one is with DataAnnotations and second one is with IDataErrorInfo (please correct me if I am wrong)? So can you confirm that the ErrorString is not empty although the Errors Collection (Dictionary) is not empty? Is it possible for you to send us more from your validation code ?

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Masoud
Top achievements
Rank 1
answered on 15 Oct 2012, 02:43 PM
Hallo Petar,

thank you für your reply.

You are right!  I write Q2 but actually I am in the middle of migration and still using Q1!

I only use DataAnnotations for validation.  The Annotation for the property is the following

[System.ComponentModel.DataAnnotations.CustomValidationAttribute(typeof(Wk.Data.BasisBaumEntityValidator),
@"ValidateRechtswert")]

Here is the validation code I use.  This is not the ValidateRechtwert from the example above but a similar and simpler method

public static ValidationResult ValidateErhoben(DateTime erhoben, ValidationContext validationContext)
{
 if (erhoben.Date > DateTime.Now.Date) 
 {
  return new ValidationResult(WkRes.Datum_Muss_Kleiner_Gleich_Heute_Sein, new [] { validationContext.MemberName });
 }
 return ValidationResult.Success;
}

The two images I uploaded show the same RadMaskedNumericInput bound to a property in my WCF RIA proxy class. 

The first image (MaskedInput-WithErrorMessage.png) shows what happens if you typed an invalid value.  The RadMaskedNumericInput has UpdateValueEvent="PropertyChanged".  So validations are called when the value is changed.  In this case all works well and the message is displayed.

The second image (MaskedInput-NoErrorMessage.png) is related to the following case.
- a WCF RIA application with a business object (WCF RIA Proxy) that has a custome validation property. 
- you add a new instance and leave the property empty

- try to insert the new entity by calling SubmitChanges on your context
- WCF RIA will now call the validation routines and will determine that the null value in the property is invalid
- RadMaskedInput shows that the property and bound control have a validation error, but are unable to show the error


I use WCF RIA, so validation is called on two occasions:
- when the binding expression is changed (Focus lost, or in the case of RadMaskedInput value changed)
- when WCF RIA attempts to submit changes to the server

RadMaskedInput is capable of detecting the validation error when the binding expression is changed. 

When I call SubmitChanges on the context, validation errors are generated in the entity (message included).  RadMaskedInput, however, doesn't display the message.

Please tell me if I am able to explain the case well enough and you are able to reproduce the error!


All the best!

 

0
Petar Mladenov
Telerik team
answered on 18 Oct 2012, 08:00 AM
Hello Klaus,

 I am afraid you have hit a known bug in our MaskedInputControls. However, it is fixed in Q2 , so we highly encourage you to upgrade. This help article demonstrates in details how the Validation should be configured in MaskedInput controls after Q2.
Please excuse us if there is any inconvenience caused.

Greetings,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ricardo
Top achievements
Rank 1
answered on 12 Feb 2015, 08:51 PM
Estoy utilizando el control de RadMaskedNumericInput, ingresando datos negativos ejem; -180.0000 y si lo trato de editarlo no se quita el signo de menos, sólo hasta que presiono de nuevo la tecla de menos, es cuando se quita. Me gustaria saber si hay alguna forma de quitar ese signo de menos con la tecla de retroseso o con suprimir
0
Petar Mladenov
Telerik team
answered on 17 Feb 2015, 09:46 AM
Hi Ricardo,

The RadMaskedInputControls do not have built in feature to remove the negative sign on pressing BackSpace or Delete. You can subcribe for KeyDown event, check whether the backSpace is pressed and multiply the Value of the Masked Control with -1. Please note that in different cultures the negative symbol can be in different places and may not be just "-" symbol but it can also be brackets (123.456).

On a side note, please submit your posts in English language, this way it will be easier for us and for the others reading the forum to understand the questions.

Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Nathaniel
Top achievements
Rank 1
answered on 28 Sep 2015, 08:27 PM
I'm not seeing the key down event raised for the backspace key.  Only keep up.  And how do I know whne it it negative zero.  When I use the debugger,  and I have -0 in the textbox, the value and text properties of the RadMaskedNumericInput are both 0.  How would I know when to multipole by -1.  What property indicates the presence of the -.
0
Petar Mladenov
Telerik team
answered on 30 Sep 2015, 06:59 AM
Hello Nathaniel,

Yes the KeyDown won't fire for the BackSpace key, because this case is handled internally in the code of the MaskedInputBase. You have two options - either inherit the control and override the HandleBackKey( several methods) or subscribe for KeyDown with AddHandler method with third parameter handledEventsToo = true.

Since in this thread we are discussing deleting the minus sign with backspace, I am attaching a sample Silverlight solution. It's the same my colleague Milena has given to you in the private thread 973405. However, I hope it will be useful to other developers too. We will consider adding this or similar sample in our SDK repository in GitHub.

Regards,
Petar Mladenov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Masoud
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Masoud
Top achievements
Rank 1
Ricardo
Top achievements
Rank 1
Nathaniel
Top achievements
Rank 1
Share this question
or