MaskedEditBox as MaskType.Standard issue

2 posts, 1 answers
  1. Mark
    Mark avatar
    66 posts
    Member since:
    Oct 2014

    Posted 19 Apr Link to this post

    I have created a class based off the MaskedEditBox. However, every time I drop it on a form, it auto populates the value with "1____-____". If I drop another on the same form, it populates the value with "2____-____".  Is this done by design?  My desired value would be "_____-____" or "" as the value.

     

    public class NtsMaskedEditBoxZipCode : RadMaskedEditBox
      {
         #region Public Constructors
     
         public NtsMaskedEditBoxZipCode()
         {
            Mask = @"99999-9999";
            MaskType = MaskType.Standard;
            Text = @"_____-____";
            TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
         }
     
         #endregion Public Constructors
     
         #region Public Properties
     
         public sealed override string Text
         {
            get { return base.Text; }
            set { base.Text = value; }
         }
     
         #endregion Public Properties
      }
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1871 posts

    Posted 20 Apr Link to this post

    Hi Mark,

    The designer is setting the text of the control. Here is how you can avoid this:
    public sealed override string Text
    {
        get { return base.Text; }
        set {
            if (this.Site != null)
            {
                return;
            }
     
            base.Text = value; }
    }

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top