Example of Multiline TextBox in ASP.NET MVC TextBox Control
This example demonstrates the multiline functionalities of the textbox control. Enter or fill the textbox with multiple rows of text. Choose the corresponding option from the property panel to update the multiline textbox.
Float Label Type
Disabled
Read only
Rows
@Html.UiTextArea("default", null, new UiTextAreaOptions { Label = "Enter your address", FloatLabelType = UiFloatLabelType.Auto, Rows = 2, ResizeMode = UiResizeMode.Both })
@Html.UiDropDownList("floatText", new UiDropDownListOptions { Width = "120px", Value = "Auto", OnChange = "floatHandler", Items = ((IEnumerable<InputsDemoController.floatValues>)ViewData["data"]).Select(f => new UiListItem(f.floatValue, f.text)).ToList() })
@Html.UiCheckBox("sample", false, new UiCheckBoxOptions { Id = "sample", OnChange = "enabledHandler" })
@Html.UiCheckBox("sample1", false, new UiCheckBoxOptions { Id = "sample1", OnChange = "readonlyHandler" })
@Html.UiNumericTextBox("rowValue", new UiNumericTextBoxOptions { Value = 2, Min = 1, Max = 20, Step = 1, Format = "N0", Width = "100px", OnChange = "rowHandler" })
<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; }
.multiline_wrapper { max-width: 250px; margin: 0 auto; padding: 40px 0 0; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section multiline">
<div class="multiline_wrapper">
@Html.UiTextArea("default", null, new UiTextAreaOptions { Label = "Enter your address", FloatLabelType = UiFloatLabelType.Auto, Rows = 2, ResizeMode = UiResizeMode.Both })
</div>
</div>
<div class="demo-property-panel property-section multiline-property" title="Properties">
<div class="property-row"><span>Float Label Type</span> @Html.UiDropDownList("floatText", new UiDropDownListOptions { Width = "120px", Value = "Auto", OnChange = "floatHandler", Items = ((IEnumerable<InputsDemoController.floatValues>)ViewData["data"]).Select(f => new UiListItem(f.floatValue, f.text)).ToList() })</div>
<div class="property-row"><span>Disabled</span> @Html.UiCheckBox("sample", false, new UiCheckBoxOptions { Id = "sample", OnChange = "enabledHandler" })</div>
<div class="property-row"><span>Read only</span> @Html.UiCheckBox("sample1", false, new UiCheckBoxOptions { Id = "sample1", OnChange = "readonlyHandler" })</div>
<div class="property-row"><span>Rows</span> @Html.UiNumericTextBox("rowValue", new UiNumericTextBoxOptions { Value = 2, Min = 1, Max = 20, Step = 1, Format = "N0", Width = "100px", OnChange = "rowHandler" })</div>
</div>
<script>
// Syncfusion: the property panel sets the float label type, the disabled and read-only states and the rows of the textbox
function textbox() { return window.Lumen.get('default'); }
function floatHandler(value) { if (value) { textbox().setFloatLabelType(value); } }
function enabledHandler(checked) { textbox()[checked ? 'disable' : 'enable'](); }
function readonlyHandler(checked) { textbox().setReadOnly(checked); }
function rowHandler(value) { textbox().setRows(value); }
</script>
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/Multiline.cshtml; it draws what ViewData holds.
public ActionResult Multiline()
{
ViewData["data"] = new floatValues().TextBoxModel();
return View();
}
public class floatValues
{
public string text { get; set; }
public string floatValue { get; set; }
public List<floatValues> TextBoxModel()
{
List<floatValues> list = new List<floatValues>();
list.Add(new floatValues { text = "Auto", floatValue = "Auto" });
list.Add(new floatValues { text = "Always", floatValue = "Always" });
list.Add(new floatValues { text = "Never", floatValue = "Never" });
return list;
}
}
}
}
@* 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>
The Multiline Textbox is used to edit or display multiple lines of text that helps you to accept address, description, comments, feedbacks, and more in a form. In this sample, rendered multiline textbox from textarea tag and the following options are available to customize it:
- Choose float label types either 'Never', 'Always', or 'Auto' to float the placeholder text.
- To make a read-only multiline textbox, check the "read-only" option.
- Disable the textbox by unchecking an "enabled" option.
- Change the number of rows count to restrict the length of the input.
Note: After resizing the multiline textbox manually, the selected rows option from the property panel is not updated to the multiline textbox.