Getting Started with ASP.NET Core TextBox Control

22 Apr 20228 minutes to read

This section briefly explains about how to include ASP.NET Core TextBox control in your ASP.NET Core application using Visual Studio.


System requirements for ASP.NET Core controls

Create ASP.NET Core web application with Razor pages

Install ASP.NET Core package in the application

Syncfusion ASP.NET Core controls are available in Refer to NuGet packages topic to learn more about installing NuGet packages in various OS environments. To add ASP.NET Core controls in the application, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for Syncfusion.EJ2.AspNet.Core and then install it.

The Syncfusion.EJ2.AspNet.Core NuGet package has dependencies, Newtonsoft.Json for JSON serialization and Syncfusion.Licensing for validating Syncfusion license key.

Add Syncfusion ASP.NET Core Tag Helper

Open ~/Views/_ViewImports.cshtml file and import the Syncfusion.EJ2 TagHelper.

@addTagHelper *, Syncfusion.EJ2

Add style sheet

Checkout the Themes topic to learn different ways (CDN, NPM package, and CRG) to refer styles in ASP.NET Core application, and to have the expected appearance for Syncfusion ASP.NET Core controls. Here, the theme is referred using CDN inside the <head> of ~/Pages/Shared/_Layout.cshtml file as follows,

    <!-- Syncfusion ASP.NET Core controls styles -->
    <link rel="stylesheet" href="" />

Add script reference

In this getting started walk-through, the required scripts are referred using CDN inside the <head> of ~/Pages/Shared/_Layout.cshtml file as follows,

    <!-- Syncfusion ASP.NET Core controls scripts -->
    <script src=""></script>

Register Syncfusion Script Manager

Open ~/Pages/Shared/_Layout.cshtml page and register the script manager at the end of `<body>` in the ASP.NET Core application as follows.

    <!-- Syncfusion ASP.NET Core Script Manager -->

Add ASP.NET Core TextBox control

Now, add the Syncfusion ASP.NET Core TextBox tag helper in ~/Pages/Index.cshtml page.

<div class="control-section">
    <div class="control_wrapper TextBox-control-section">
        <ejs-textbox id="firstname" placeholder="First Name"></ejs-textbox>

Press Ctrl+F5 (Windows) or +F5 (macOS) to run the app. Then, the Syncfusion ASP.NET Core TextBox control will be rendered in the default web browser.

ASP.NET Core TextBox Control

Adding icons to the TextBox

You can create a TextBox with icon as a group by creating the parent div element with the class e-input-group and add the icon element as span with the class e-input-group-icon. For detailed information, refer to the Groups section.

<div class="control-section">
    <div class="control_wrapper TextBox-control-section">
        <div class="e-input-group">
            <input class="e-input" name='input' type="text" placeholder="Enter Date" />
            <span class="e-input-group-icon e-input-popup-date"></span>
    var inputObject = {};
    var input = document.querySelectorAll('.e-input-group .e-input,.e-float-input.e-input-group input');
    var inputIcon = document.querySelectorAll('.e-input-group-icon');
    var focusFn = function (index) {
        return function () {
    var blurFn = function (index) {
        return function () { getParentNode(input[index]).classList.remove('e-input-focus'); };
    var mouseupFn = function () {
        var ele = this; setTimeout(function () {
        }, 500);
    for (var i = 0; i < input.length; i++) {
        input[i].addEventListener('focus', focusFn(i));
        input[i].addEventListener('blur', blurFn(i));
    for (var j = 0; j < inputIcon.length; j++) {
        inputIcon[j].addEventListener('mousedown', function () {
        inputIcon[j].addEventListener('mouseup', mouseupFn);
    function getParentNode(element) {
        var parentNode = element.parentNode;
        if (parentNode.classList.contains('e-input-in-wrap')) {
            return parentNode.parentNode;
        return parentNode;
    .e-input-group-icon:before {
        font-family: e-icons;

    .e-input-group .e-input-group-icon.e-input-popup-date { /* csslint allow: adjoining-classes */
        font-size: 16px;

    .e-input-group-icon.e-input-popup-date:before { /* csslint allow: adjoining-classes */
        content: "";

    .e-input-group-icon.e-input-up:before { /* csslint allow: adjoining-classes */
        content: '\e85e';


ASP.NET Core TextBox with Icon

Floating label

The floating label TextBox floats the label above the TextBox after focusing, or filled with value in the TextBox. You can create the floating label TextBox by using the floatLabelType API

<div class="control-section">
    <div class="control_wrapper TextBox-control-section">
        <ejs-textbox id="firstname" placeholder="First Name" floatLabelType="Auto"></ejs-textbox>

ASP.NET Core TextBox with Floating Label

View Sample in GitHub.

See also