Rows and Columns in ASP.NET MVC TextArea Control

14 Jun 20241 minute to read

Two essential attributes, rows and columns, play a pivotal role in customizing the TextArea’s appearance and layout.
The rowsattribute determines the initial visible number of lines within the TextArea, controlling its vertical size. Conversely, the columns attribute specifies the visible width of the TextArea in characters per line, determining its initial width.

  • You can customize the TextArea control by setting the number of rows using the Rows property and the number of columns using the Cols property. These properties allow precise control over the dimensions of the TextArea, ensuring it fits seamlessly within the layout of the application.
<div class="control-section">
    <div class="control_wrapper textarea-control-section">
        <div>
            @Html.EJS().TextArea("default1").Placeholder("Enter your comments").FloatLabelType(FloatLabelType.Auto).Rows(3).Cols(35).Render()
        </div>
        <div>
            @Html.EJS().TextArea("default2").Placeholder("Enter your comments").FloatLabelType(FloatLabelType.Auto).Rows(5).Cols(40).Render()
        </div>
    </div>
</div>
public ActionResult RowsCols()
{
    return View();
}

Output be like the below.

textarea