Example of Default Functionalities in ASP.NET MVC TextArea Control
This example demonstrates the default functionalities of the TextArea control. Type a character in the TextArea element or focus-in to the TextArea for floating the label text. The label will be positioned back to TextArea on focus-out without value.
Outlined and Filled
Please leave a comment
Validation States
@Html.UiTextArea("outlined", null, new UiTextAreaOptions { Label = "Outlined", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, CssClass = "ui-input-outlined" })
@Html.UiTextArea("filled", null, new UiTextAreaOptions { Label = "Filled", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, CssClass = "ui-input-filled" })
@Html.UiTextArea("default", null, new UiTextAreaOptions { Label = "Enter your comments", FloatLabelType = UiFloatLabelType.Auto, Rows = 5 })
@Html.UiTextArea("stateSuccess", null, new UiTextAreaOptions { Placeholder = "Success", Rows = 5, CssClass = "ui-input-success" })
@Html.UiTextArea("stateWarning", null, new UiTextAreaOptions { Placeholder = "Warning", Rows = 5, CssClass = "ui-input-warning" })
@Html.UiTextArea("stateError", null, new UiTextAreaOptions { Placeholder = "Error", Rows = 5, CssClass = "ui-input-error" })
<style>
.content-wrapper { width: 90%; margin: 0 auto; min-width: 185px; }
.content-wrapper .ta-row { padding: 12px 0; }
.content-wrapper .ta-cols { display: flex; gap: 24px; }
.content-wrapper .ta-cols > * { flex: 1 1 0; min-width: 0; }
.content-wrapper .ta-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; }
.property-section .prop-input { width: 130px; 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; }
</style>
<div class="control-section" id="textarea-default">
<div class="content-wrapper">
<div class="ta-title">Outlined and Filled</div>
<div class="ta-row ta-cols">
@Html.UiTextArea("outlined", null, new UiTextAreaOptions { Label = "Outlined", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, CssClass = "ui-input-outlined" })
@Html.UiTextArea("filled", null, new UiTextAreaOptions { Label = "Filled", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, CssClass = "ui-input-filled" })
</div>
<div class="ta-title">Please leave a comment</div>
<div class="ta-row">
@Html.UiTextArea("default", null, new UiTextAreaOptions { Label = "Enter your comments", FloatLabelType = UiFloatLabelType.Auto, Rows = 5 })
</div>
<div class="ta-title">Validation States</div>
<div class="ta-row ta-cols">
@Html.UiTextArea("stateSuccess", null, new UiTextAreaOptions { Placeholder = "Success", Rows = 5, CssClass = "ui-input-success" })
@Html.UiTextArea("stateWarning", null, new UiTextAreaOptions { Placeholder = "Warning", Rows = 5, CssClass = "ui-input-warning" })
@Html.UiTextArea("stateError", null, new UiTextAreaOptions { Placeholder = "Error", Rows = 5, CssClass = "ui-input-error" })
</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 TextAreaController : Controller
{
// The page is Views/TextArea/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 TextArea is an input element that allows users to input multiple lines of text. It can be used for editing or displaying text data.
| Types | Description |
|---|---|
| Outlined & Filled textarea | 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.
|
| Default TextArea | You can render textarea by adding class as e-input. You can also render textarea as group by adding parent element with e-input-group class added. |
| Validation states | You can apply validation states success, warning, error to the textarea with the corresponding classes added to the input element such as e-success, e-warning, e-error. |