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

MaskedEditBox as MaskType.Standard issue

1 Answer 51 Views
MaskedEditBox
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 19 Apr 2017, 03:39 PM

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
  }

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Apr 2017, 08:33 AM
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.
Tags
MaskedEditBox
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Dimitar
Telerik team
Share this question
or