aspnet-devexpress-dot-web-dot-masksettings.md
Gets or sets a mask expression.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue("")]
public string Mask { get; set; }
<DefaultValue("")>
Public Property Mask As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A string representing a mask expression.
|
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
|
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
<dx:ASPxTextBox ID="txtZip" runat="server">
<MaskSettings Mask="00000" PromptChar="#" />
</dx:ASPxTextBox>
<dx:ASPxTextBox ID="txtPhone" runat="server">
<MaskSettings Mask="+1 (999) 000-0000" IncludeLiterals="None" />
</dx:ASPxTextBox>
<dx:ASPxTextBox ID="txtPrice" runat="server" >
<MaskSettings Mask="$<0..99999g>.<00..99>" IncludeLiterals="DecimalSymbol" />
</dx:ASPxTextBox>
<dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="Custom"
UseMaskBehavior="true" EditFormatString="MMMM dd, yyyy" >
</dx:ASPxDateEdit>
<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()
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.
case BusinessObjects.EditMask.Date:
textEdit.MaskSettings.Mask = "MM/dd/yyyy";
break;
Case BusinessObjects.EditMask.Date
textEdit.MaskSettings.Mask = "MM/dd/yyyy"
Case BusinessObjects.EditMask.Time
See Also