$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
How to Build MaskedTextBox Input Using C#
Home > How to > Input MaskedTextBox

By using KT.UI PerMaskedTextBox Input component, users can easily and quickly set and distinguish proper and improper user input by setting the MaskedTextBox property. Users can use the Mask property within C# ASP.NET application to specify the supportable format on entered texts.

How to Use C# Codes to Set Mask and DisplayMask Porperties

  • Mask: this property refers to the input data form in the textbox.
  • DisplayMask: the default value when there is no any input data in textbox and it will prompt users what kind of data needs to be entered.

PerMaskedTextBox1.Mask = "#### #### #### ####";
PerMaskedTextBox1.DisplayMask = PerButton3.Checked ? "#### #### #### ####" : "";

How to Use C# Codes to Set other Property

By using our reliable and excellent PerMaskedTextBox Input control, users can set and define the mask at run time in various ways, which can control the way that the mask can be used. Please see the brief introductions to following three properties.
  • AllowEmptyEnumerations: this property can be used to allow the enumerated parts of the mask to be set as blank.
  • ZeroPadNumericRanges: this property restricts the values of numeric range parts of the mask with a fixed and stable width.
  • NumericRangeAlign: users can use this property to set whether align the values of numeric range parts to the left or to the right.
Please check out following C# codes for this property.
PerMaskedTextBox1.ZeroPadNumericRanges = true;

How to Use C# Codes to Set Focus

When users are not editing the value in the NumericTextBox or the text box does not have focus, you can build and set different appearance for the masked text box.
Two properties' explanations on setting focus.
  • PromptChar: when apply PerMaskedTextBox control at run time; the text box will display a set of prompt characters for the text value that users need to enter. Users can specify the mask prompt character by using and setting PromptChar property.
  • DisplayPromptChar: when set the DisplayMaks property as true, users can use this property to set and change the prompt character for unentered value when the masked text box does not have focus.
Please see following C# sample codes on setting focus.
PerMaskedTextBox1.PromptChar = "_";
PerMaskedTextBox1.DisplayPromptChar = " ";

How to Use C# Codes to Set MultiLine Mode

With support of PerMaskedTextBox Input control, users are allowed to use PerMaskedTextBox component to display the texts in text box in multiple lines. Please feel free to directly copy following sample C# codes to set multi-line mode.
PerMaskedTextBox1.TextMode = InputMode.MultiLine;
PerMaskedTextBox1.Rows = 5;
PerMaskedTextBox1.Width = 230;
PerMaskedTextBox1.Height = 90;
PerMaskedTextBox1.Mask="Telephone: (###) ###-####-####\r\nF\ax: (###) ###-####-####\r\nZip code: #####-####";
ASP.NET AJAX UI Controls