RadMaskedTextInput - Clearing the Editor

3 posts, 0 answers
  1. Preston
    Preston avatar
    19 posts
    Member since:
    Apr 2009

    Posted 22 Jul 2012 Link to this post

    Telerik Team,

    I have the following RadMaksedTextInput setup:

    <telerik:RadMaskedTextInput Mask="###-##-####"                                      
                       Value="{Binding Value, Mode=TwoWay}"/>

    This is bound to a nullable double that ultimately reflects a social security number, hence the associated format.  Once a number has been entered into the editor and then ultimately cleared (the entire value is highlighted and deleted or the last available value is deleted), the "Value" property, in which the control is bound to, is never updated.  It remains as the last non-null or not-empty value.  In this particular case, I would expect the property to be set to null.  How can I achieve this behavior?

    Thanks in advance

  2. Alex Fidanov
    Alex Fidanov avatar
    636 posts

    Posted 26 Jul 2012 Link to this post

    Hi Preston,

     If I understand your scenario correctly, you are binding the masked text input (which value type is string) to a double value. This should throw some exceptions in the output about not being able to convert string to double. Perhaps, this is the reason why the value does not update. I would recommend using a IValueConverter with the binding between the editor and your value that would convert string to double and double to string. When the value is cleared, the result is an empty string and it cannot be properly converted to double (or nullable double).

    Alex Fidanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Preston
    Preston avatar
    19 posts
    Member since:
    Apr 2009

    Posted 30 Jul 2012 Link to this post


    You are absolutely right, a converter fixed the problem.  However, I still find it odd that the proper conversion is exhibited with any edits other than clearing the editor.  Nevertheless, my problem is solved.  Thanks for your timely response.

Back to Top