MaskedTextBox

Wisej.Web.MaskedTextBox

Namespace: Wisej.Web

Assembly: Wisej.Framework (3.5.0.0)

Uses a mask to distinguish between proper and improper user input.

public class MaskedTextBox : TextBoxBase

The MaskedTextBox class is an enhanced TextBox control that supports a declarative syntax for accepting or rejecting user input. Using the Mask property, you can enforce the following input types without writing any custom validation logic in your application:

  • Required input characters.

  • Optional input characters.

  • The type of input expected at a given position in the mask; for example, a digit, or an alphabetic or alphanumeric character.

  • Mask literals, or characters that should appear directly in the MaskedTextBox; for example, the hyphens(-) in a phone number, or the currency symbol in a price.

  • Special processing for input characters; for example, to convert alphabetic characters to uppercase.

  • Special processing for input characters; for example, to convert alphabetic characters to uppercase.

When a MaskedTextBox control is displayed at run time, it represents the mask as a series of prompt characters and optional literal characters. Each editable mask position, representing a required or optional input, is shown with a single prompt character. For example, the number sign (#) is often used as a placeholder for a numeric character input. You can use the PromptChar property to specify a custom prompt character. The HidePromptOnLeave property determines if the user sees the prompt characters when the control loses input focus

Constructors

Initializes a new instance of the MaskedTextBox class using defaults.

Initializes a new instance of the MaskedTextBox class with specific initial settings.

Initializes a new instance of the MaskedTextBox class with specific initial settings.

Initializes a new instance of the MaskedTextBox class with specific initial settings.

Initializes a new instance of the MaskedTextBox class with specific initial settings.

Initializes a new instance of the MaskedTextBox class with specific initial settings.

Properties

CharacterCasing: Returns or sets whether the MaskedTextBox control modifies the case of characters as they are typed. (Default: Normal)

CultureInfo: Returns or sets the culture information associated with the masked text box.

String: Returns or sets a JavaScript regular expression that limits the characters that the user can type. (Default: null)

Boolean: Returns or sets whether the prompt characters in the input mask are hidden when the masked text box loses focus. (Default: False)

InputType: Specifies the type, min, max and step properties to associate to the <input> element. (Default: null)

String: Returns or sets the input mask. (Default: "")

The Mask is a string that defines the masking characters and the literals to display and process during user input and when reading the Text property. Server side masking is processed by an instance of the MaskedTextProvider class exposed by the MaskedTextProvider property. On the client side, the mask processing is performed by the "wisej.utils.MaskProvider.js" class while the user edits the input field.

If you change the Mask when the control already contains a value, it will apply the new mask to the existing text. The decimal (.), thousand (,), time (:), date (/), and currency ($) symbols default to displaying those symbols as defined by the application's culture. You can force a specific MaskedTextBox to display symbols for another culture by using the Culture property. Otherwise you can set the application-wide culture by setting the CurrentCulture property.

MaskedTextProvider: Returns the mask provider associated with this instance of the masked text box control.

Char: Returns or sets the character used to mask characters of a password in a single-line MaskedTextBox control. (Default: "\0")

This property only enables/disables the password mode for the textbox. It doesn't change the password masking character used by the browser.

Char: Returns or sets the character used to represent the absence of user input in the MaskedTextBox control. (Default: _)

Throws:

  • ArgumentException The character specified when setting this property is not a valid prompt character.

Boolean: Returns or sets whether the parsing of input text should stop after the first invalid character is reached. (Default: False)

Boolean: Returns or sets whether the text in the MaskedTextBox is spell checked by the browser. (Default: False)

String: Returns or sets the current text in the text box. (Default: "")

HorizontalAlignment: Returns or sets how text is aligned in a TextBox control. (Default: Left)

Int32: Returns the length of text in the control.

MaskFormat: Returns or sets a value that determines whether literals and prompt characters are included in the formatted string. (Default: IncludeLiterals)

Type: Returns or sets the data type used to verify the data input by the user. (Default: null)

Methods

Converts the user input string to an instance of the validating type.

Returns: Object. If successful, an Object of the type specified by the ValidatingType property; otherwise, null to indicate conversion failure.

Throws:

  • Exception A critical exception occurred during the parsing of the input string.

Events

EventHandler Fired when the value of the Culture property has changed.

EventHandler Fired when the value of the Mask property has changed.

EventHandler Fired when the value of the TextAlign property has changed.

TypeValidationEventHandler Occurs when MaskedTextBox has finished parsing the current value using the ValidatingType property.

Inherited By

Implements

Last updated