Example of Default Functionalities in ASP.NET MVC TextBox Control
This example demonstrates the default functionalities of the TextBox control. Type a character in the TextBox element or focus-in to the TextBox for floating the label text. The label will be positioned back to TextBox on focus-out without value.
Outlined and Filled
Floating Label
Inputs
Validation States
Sizing
Input & Elements
@Html.UiTextBox("outlined", null, new UiTextBoxOptions { Label = "Outlined", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-outlined" })
@Html.UiTextBox("filled", null, new UiTextBoxOptions { Label = "Filled", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-filled" })
@Html.UiTextBox("firstname", null, new UiTextBoxOptions { Label = "First Name", FloatLabelType = UiFloatLabelType.Auto })
@Html.UiTextBox("lastname", null, new UiTextBoxOptions { Label = "Last Name", FloatLabelType = UiFloatLabelType.Auto, HtmlAttributes = new { dir = "rtl" } })
@Html.UiTextBox("country", null, new UiTextBoxOptions { Label = "Country", FloatLabelType = UiFloatLabelType.Auto })
@Html.UiTextBox("inputName", null, new UiTextBoxOptions { Placeholder = "Enter Name" })
@Html.UiTextBox("inputLast", null, new UiTextBoxOptions { Placeholder = "Last Name", HtmlAttributes = new { dir = "rtl" } })
@Html.UiTextBox("inputPassword", "password", new UiTextBoxOptions { Placeholder = "Password", Type = UiTextBoxType.Password })
@Html.UiTextBox("inputEmail", null, new UiTextBoxOptions { Placeholder = "Enter Email", Type = UiTextBoxType.Email })
@Html.UiTextBox("inputDisabled", null, new UiTextBoxOptions { Placeholder = "Disabled", Enabled = false })
@Html.UiTextBox("inputReadonly", "Readonly", new UiTextBoxOptions { Placeholder = "Enter Name", ReadOnly = true })
@Html.UiTextBox("stateSuccess", null, new UiTextBoxOptions { Placeholder = "Success", CssClass = "ui-input-success" })
@Html.UiTextBox("stateWarning", null, new UiTextBoxOptions { Placeholder = "Warning", CssClass = "ui-input-warning" })
@Html.UiTextBox("stateError", null, new UiTextBoxOptions { Placeholder = "Error", CssClass = "ui-input-error" })
@Html.UiTextBox("sizeSmall", null, new UiTextBoxOptions { Placeholder = "Small", Size = UiInputSize.Small })
@Html.UiTextBox("sizeNormal", null, new UiTextBoxOptions { Placeholder = "Normal" })
@Html.UiTextBox("dob", null, new UiTextBoxOptions { Placeholder = "Date of Birth", AppendTemplate = "#tbDateIcon" })
@Html.UiTextBox("picture", null, new UiTextBoxOptions { Placeholder = "Upload Picture", PrependTemplate = "#tbPictureIcon" })
<style>
.content-wrapper { width: 90%; margin: 0 auto; min-width: 185px; }
.content-wrapper .tb-row { display: flex; gap: 24px; padding: 12px 0; }
.content-wrapper .tb-row > * { flex: 1 1 0; min-width: 0; }
.content-wrapper .tb-title { padding: 15px 0 0; font-weight: 700; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
</style>
<template id="tbDateIcon"><span class="e-icons e-calendar"></span></template>
<template id="tbPictureIcon"><span class="e-icons e-upload-picture"></span></template>
<div class="control-section">
<div class="content-wrapper">
<div class="tb-title">Outlined and Filled</div>
<div class="tb-row">
<div>@Html.UiTextBox("outlined", null, new UiTextBoxOptions { Label = "Outlined", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-outlined" })</div>
<div>@Html.UiTextBox("filled", null, new UiTextBoxOptions { Label = "Filled", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-filled" })</div>
</div>
<div class="tb-title">Floating Label</div>
<div class="tb-row">
<div>@Html.UiTextBox("firstname", null, new UiTextBoxOptions { Label = "First Name", FloatLabelType = UiFloatLabelType.Auto })</div>
<div>@Html.UiTextBox("lastname", null, new UiTextBoxOptions { Label = "Last Name", FloatLabelType = UiFloatLabelType.Auto, HtmlAttributes = new { dir = "rtl" } })</div>
</div>
<div class="tb-row">
<div>@Html.UiTextBox("country", null, new UiTextBoxOptions { Label = "Country", FloatLabelType = UiFloatLabelType.Auto })</div>
</div>
<div class="tb-title">Inputs</div>
<div class="tb-row">
<div>@Html.UiTextBox("inputName", null, new UiTextBoxOptions { Placeholder = "Enter Name" })</div>
<div>@Html.UiTextBox("inputLast", null, new UiTextBoxOptions { Placeholder = "Last Name", HtmlAttributes = new { dir = "rtl" } })</div>
</div>
<div class="tb-row">
<div>@Html.UiTextBox("inputPassword", "password", new UiTextBoxOptions { Placeholder = "Password", Type = UiTextBoxType.Password })</div>
<div>@Html.UiTextBox("inputEmail", null, new UiTextBoxOptions { Placeholder = "Enter Email", Type = UiTextBoxType.Email })</div>
</div>
<div class="tb-row">
<div>@Html.UiTextBox("inputDisabled", null, new UiTextBoxOptions { Placeholder = "Disabled", Enabled = false })</div>
<div>@Html.UiTextBox("inputReadonly", "Readonly", new UiTextBoxOptions { Placeholder = "Enter Name", ReadOnly = true })</div>
</div>
<div class="tb-title">Validation States</div>
<div class="tb-row">
<div>@Html.UiTextBox("stateSuccess", null, new UiTextBoxOptions { Placeholder = "Success", CssClass = "ui-input-success" })</div>
<div>@Html.UiTextBox("stateWarning", null, new UiTextBoxOptions { Placeholder = "Warning", CssClass = "ui-input-warning" })</div>
<div>@Html.UiTextBox("stateError", null, new UiTextBoxOptions { Placeholder = "Error", CssClass = "ui-input-error" })</div>
</div>
<div class="tb-title">Sizing</div>
<div class="tb-row">
<div>@Html.UiTextBox("sizeSmall", null, new UiTextBoxOptions { Placeholder = "Small", Size = UiInputSize.Small })</div>
<div>@Html.UiTextBox("sizeNormal", null, new UiTextBoxOptions { Placeholder = "Normal" })</div>
</div>
<div class="tb-title">Input & Elements</div>
<div class="tb-row">
<div>@Html.UiTextBox("dob", null, new UiTextBoxOptions { Placeholder = "Date of Birth", AppendTemplate = "#tbDateIcon" })</div>
<div>@Html.UiTextBox("picture", null, new UiTextBoxOptions { Placeholder = "Upload Picture", PrependTemplate = "#tbPictureIcon" })</div>
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TextBoxController : Controller
{
// The page is Views/TextBox/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
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>
A TextBoxes are an input element that allows to get input from the user. It allows the user either to edit or display the input values.
| Types | Description |
|---|---|
| Outlined & Filled textbox | You can render the following two types of text fields in the material theme by adding e-outline and e-filled class to cssClass API.
|
| Floating Label | You can render floating textbox with e-float-input class added and need to maintain the following structure of elements.
|
| Floating Label & Elements | You can render floating textbox with icons added with in group element e-input-group and need to maintain the following structure of elements.
|
| Default TextBox | You can render textbox by adding class as e-input.You can also render textbox as group by adding parent element with e-input-group class added. |
| RTL TextBox | Set e-input and e-rtl classes to render textbox in right to left direction. For rendering group in RTL mode , class list will be like e-input-group e-rtl. |
| Disabled TextBox | You set html disabled attribute to textbox. For parent group element , you can disable it by adding e-disabled class. |
| Readonly TextBox | You set html readonly attribute to textbox. |
| Validation states | You can apply validation states success, warning, error to the textbox with the corresponding classes added to the input element such as e-success, e-warning, e-error. |
| Sizing | You can render small sizing textbox by adding e-small class to the input element. By default normal size considered. |
| Input & elements | You can render textbox with icons in the below format,
|