New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Prefix and Suffix

The NumericTextBox component provides options for enhancing the user interface interactivity by adding custom content as prefix and suffix adornments.

The prefix and suffix input adornments are elements positioned before and after the NumericTextBox input element, commonly used to clarify the expected data in the input, such as currency symbols or unit indicators, and provide direct functionality for the entered data, like password visibility toggles, formatting, and more.

Prefix

The prefix input adornment is placed before the NumericTextBox field and provides an additional context that guides users in entering specific data, such as icons for currencies or unit indicators. To configure the Prefix functionality, use the PrefixOptions() configuration, which facilitates the following options:

  • Icon()—Inserts an icon before the NumericTextBox element. The option accepts the name of an existing icon in the Kendo UI theme or SVG content.
  • Template()—Adds custom content before the NumericTextBox element. You can use a variety of templating options like TemplateId(), TemplateHandler(), and more.
  • Separator()—By default, the separator is visible. Disable the Separator() option to remove the default separator of the prefix content.

The following example demonstrates how to add a DropDownList component before the NumericTextBox.

    @(Html.Kendo().NumericTextBox()
        .Name("length")
        .Placeholder("Enter length")
        .PrefixOptions(prefix => prefix.TemplateId("prefixTemplate"))
    )

    <script type="text/x-kendo-template" id="prefixTemplate">
        @(Html.Kendo().DropDownList()
            .Name("length-units")
            .Size(ComponentSize.Small)
            .FillMode(FillMode.Flat)
            .Rounded(Rounded.None)
            .BindTo(new List<string>() {
                "mm",
                "cm",
                "m",
                "km"
            })
            .HtmlAttributes(new { style = "width: 70px;" })
            .ToClientTemplate()
        )
    </script>

Suffix

The suffix input adornment is an element positioned after the input field. Usually, it offers direct functionality related to the entered data, such as toggles for password visibility, formatting options, or the ability to clear the input. Set up the Suffix functionality through the SuffixOptions() configuration that provides the following options:

  • Icon()—Adds an icon after the NumericTextBox element. The option accepts the name of an existing icon in the Kendo UI theme or SVG content.
  • Template()—Adds custom content for the suffix adornment of the NumericTextBox.
  • Separator()—By default, the separator is visible. Disable the Separator() option to remove the default separator of the suffix content.

The following example demonstrates how to insert HTML content after the NumericTextBox element.

    @(Html.Kendo().NumericTextBox()
        .Name("length")
        .Placeholder("Enter length")
        .SuffixOptions(suffix => suffix.Separator(false).Template("<div class='selected-length-unit' id='selected-unit'>mm</div>"))
    )

See Also

In this article