Example of Resize in ASP.NET MVC TextArea Control
This example demonstrates the resize functionalities of the textarea control. Choose the corresponding resizeMode option from the property panel to update the resize behavior in the textarea.
Resize Mode
@Html.UiTextArea("resize", null, new UiTextAreaOptions { Label = "Enter your comments", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, ResizeMode = UiResizeMode.Vertical })
@Html.UiDropDownList("select", new UiDropDownListOptions { Width = "120px", Value = "Vertical", OnChange = "resizeHandler", Items = ((IEnumerable<InputsDemoController.resizeValues>)ViewData["data"]).Select(r => new UiListItem(r.resizeValue, r.text)).ToList() })
<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; }
.resize .ta-row { padding: 40px 0 0; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section resize">
<div id="textarea-resize" class="content-wrapper">
<div class="ta-row">
@Html.UiTextArea("resize", null, new UiTextAreaOptions { Label = "Enter your comments", FloatLabelType = UiFloatLabelType.Auto, Rows = 5, ResizeMode = UiResizeMode.Vertical })
</div>
</div>
</div>
<div class="demo-property-panel property-section" title="Properties">
<div class="property-row"><span>Resize Mode</span> @Html.UiDropDownList("select", new UiDropDownListOptions { Width = "120px", Value = "Vertical", OnChange = "resizeHandler", Items = ((IEnumerable<InputsDemoController.resizeValues>)ViewData["data"]).Select(r => new UiListItem(r.resizeValue, r.text)).ToList() })</div>
</div>
<script>
// Syncfusion: the list sets the resize mode of the textarea
function resizeHandler(value) { if (value) { window.Lumen.get('resize').setResizeMode(value); } }
</script>
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/Resize.cshtml; it draws what ViewData holds.
public ActionResult Resize()
{
ViewData["data"] = new resizeValues().TextAreaModel();
return View();
}
public class resizeValues
{
public string text { get; set; }
public string resizeValue { get; set; }
public List<resizeValues> TextAreaModel()
{
List<resizeValues> list = new List<resizeValues>();
list.Add(new resizeValues { text = "Both", resizeValue = "Both" });
list.Add(new resizeValues { text = "Horizontal", resizeValue = "Horizontal" });
list.Add(new resizeValues { text = "Vertical", resizeValue = "Vertical" });
list.Add(new resizeValues { text = "None", resizeValue = "None" });
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 textarea can be resized vertically, horizontally, or in both directions by selecting the following corresponding options:
- Choose resizeMode options such as 'Both', 'Vertical', 'Horizontal', or 'None' to control the resize behavior of the textarea.