MaskSettings.Mask Property
Gets or sets a mask expression.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
#Property Value
Type | Default | Description |
---|---|---|
String | String. |
A string representing a mask expression. |
#Property Paths
You can access this nested property as listed below:
Object Type | Path to Mask |
---|---|
ASPx |
|
ASPx |
|
Button |
|
Text |
|
#Remarks
Applying a mask to the editor restricts the text that end-users can enter. If masked mode is enabled, the editor validates the text against the mask, and only allows data that satisfies the mask expression to be entered. To enable masked mode for an editor, specify the mask using the Mask property.
Note
- Defining a text box editor’s mask via the editor’s Mask property automatically activates the editor’s built-in validation functionality. This might affect the editor appearance, because extra space may be required for an error image and text to be displayed for invalid input, due to an editor’s default validation settings. To customize the editor appearance in this case, use the validation properties available via the editor’s ASPx
Edit. property (for instance, you can modify the ValidationValidation Settings Settings. or ValidationDisplay Settings. property, etc). You can also provide a mask-specific error text via the MaskError Display Mode Settings. property of an editor.Error Text - The control validates the masked value only if it is in string format. Otherwise, the validation fails. For more information, refer to the T816004: Grid-like components validate column editor values against editor-specific settings and mark editors whose values do not pass validation as invalid ticket.
#Example
- Zip code
<dx:ASPxTextBox ID="txtZip" runat="server">
<MaskSettings Mask="00000" PromptChar="#" />
</dx:ASPxTextBox>
- Phone Number
<dx:ASPxTextBox ID="txtPhone" runat="server">
<MaskSettings Mask="+1 (999) 000-0000" IncludeLiterals="None" />
</dx:ASPxTextBox>
- Price
<dx:ASPxTextBox ID="txtPrice" runat="server" >
<MaskSettings Mask="$<0..99999g>.<00..99>" IncludeLiterals="DecimalSymbol" />
</dx:ASPxTextBox>
- Date
<dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="Custom"
UseMaskBehavior="true" EditFormatString="MMMM dd, yyyy" >
</dx:ASPxDateEdit>
- Promo Code
<dx:ASPxTextBox ID="txtPromoCode" runat="server" >
<MaskSettings ShowHints="true" Mask="<HOME|*BUSINESS>->aaaa-aaaa" />
</dx:ASPxTextBox>
MVC:
@Html.DevExpress().TextBox(settings => {
settings.Name = "textBox3";
settings.Width = Unit.Percentage(100);
settings.Properties.MaskSettings.Mask = "+1 (999) 000-0000";
settings.Properties.MaskSettings.IncludeLiterals = MaskIncludeLiteralsMode.None;
settings.Properties.MaskSettings.ErrorText = "Invalid Phone Number";
settings.Properties.ValidationSettings.Display = Display.Dynamic;
}).GetHtml()
#Concepts
#Online Demos
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Mask property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.