Example of Adornments in ASP.NET MVC MaskedTextBox Control
This example highlights adornment support in the Syncfusion MaskedTextBox. Adornments let you place custom elements before or after the masked input by using the prependTemplate and appendTemplate properties such as prefixes, suffix labels, or action icons to provide context, guide entry, and offer quick actions, while preserving mask validation and float label behavior.
@Html.UiMaskedTextBox("maskTemplate", new UiMaskedTextBoxOptions { Mask = "0000-000-000", PromptChar = '#', Label = "Enter phone number", FloatLabelType = UiFloatLabelType.Auto, PrependTemplate = "#maskUser", AppendTemplate = "#maskSend" })
<style>
.content-wrapper { width: 90%; max-width: 400px; margin: 0 auto; min-width: 185px; }
.content-wrapper .control-label { padding: 24px 0 4px; font-size: 12px; opacity: 0.7; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.property-section .prop-input { width: 150px; padding: 4px 6px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
.mask-row { padding-top: 40px; }
</style>
<template id="maskUser"><span id="user" class="e-icons e-user" title="User"></span><span class="ui-input-separator"></span></template>
<template id="maskSend"><span class="ui-input-separator"></span><span id="sendIcon" class="e-icons e-send"></span></template>
<div class="control-section">
<div class="content-wrapper mask-row">
@Html.UiMaskedTextBox("maskTemplate", new UiMaskedTextBoxOptions { Mask = "0000-000-000", PromptChar = '#', Label = "Enter phone number", FloatLabelType = UiFloatLabelType.Auto, PrependTemplate = "#maskUser", AppendTemplate = "#maskSend" })
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class MaskedTextBoxController : Controller
{
// The page is Views/MaskedTextBox/Adornments.cshtml; it draws what ViewData holds.
public ActionResult Adornments()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
This sample illustrates adornment integration in the Syncfusion MaskedTextBox via a prepended user icon and a appended send icon.