Saving the format of the value in a masked control

2 posts, 0 answers
  1. Babak
    Babak avatar
    9 posts
    Member since:
    Jan 2014

    Posted 29 Apr 2014 Link to this post

    I am using Silverlight and RadMaskedInputText but I think this can be a more general question:Let's say I have a control that accepts masked input like
     ###-###-#### and I enter 710- -9830
    For some reason when I save the value into the database it is saved as 7109830
    so next time that the form loads the mask will show 710-980-3 which is wrong.
    What do you think is the root cause of the issue and how can I fix it?

    <Setter Property="Mask" Value="###-###-####"></Setter>
    <Setter Property="Placeholder" Value=" " />
  2. Martin
    Martin avatar
    1044 posts

    Posted 30 Apr 2014 Link to this post

    Hello Babak,

    Note that this behavior is expected because the Value property of the masked input controls holds only the value and excludes the mask symbols. In order to save the value with the mask characters of the input control you can save also the Text property of the RadMaskedInputText. This property holds the value and the mask symbols which was used in the input. You can also take a look at the Data binding with RadMaskedTextInput forum which addresses an issue similar to yours. Basically you can bind the Value one way, this will get the string from the DB and then bind the Text OneWayToSource, this will always preserve the value with the mask symbols.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft R3 2016 release webinar banner
Back to Top