Skip to main content
Tab

MaskSettings.Mask Property

Gets or sets a mask expression.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue("")]
public string Mask { get; set; }

Property Value

Type Default Description
String String.Empty

A string representing a mask expression.

Property Paths

You can access this nested property as listed below:

Object Type Path to Mask
ASPxButtonEdit
.MaskSettings .Mask
ASPxTextBox
.MaskSettings .Mask
ButtonEditProperties
.MaskSettings .Mask
TextBoxProperties
.MaskSettings .Mask

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

Example

  • Zip code

MaskSettings.Mask Property - Zip Code

<dx:ASPxTextBox ID="txtZip" runat="server">
    <MaskSettings Mask="00000" PromptChar="#" />
</dx:ASPxTextBox>
  • Phone Number

MaskSettings.Mask Property - Phone Number

<dx:ASPxTextBox ID="txtPhone" runat="server">
    <MaskSettings Mask="+1 (999) 000-0000" IncludeLiterals="None" />
</dx:ASPxTextBox>
  • Price

MaskSettings.Mask Property - Price

<dx:ASPxTextBox ID="txtPrice" runat="server" >
    <MaskSettings Mask="$<0..99999g>.<00..99>" IncludeLiterals="DecimalSymbol" />
</dx:ASPxTextBox>
  • Date

MaskSettings.Mask Property - Date

<dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="Custom" 
UseMaskBehavior="true" EditFormatString="MMMM dd, yyyy" >
</dx:ASPxDateEdit>
  • Promo Code

MaskSettings.Mask Property - 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

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.

See Also