Let’s see how to use the textarea tag helper to generate a textarea element in a form. We have the following model which will be used by our example.
public class Student
{
public string Notes { get; set; }
}
Now at the top of the view we define the model which will be used by our view.
@model Student
Finally, we have the form tag helper which contains our textarea tag helper.
<form asp-controller="Home" asp-action="Index">
<textarea asp-for="Notes"></textarea>
<input class="btn btn-success" type="submit" />
</form>
This code will generate the following HTML.
<form action="/" method="post">
<textarea id="Notes" name="Notes"></textarea>
<input class="btn btn-success" type="submit" />
<input name="__RequestVerificationToken" type="hidden" value="CfDJ8Cc6bJ3TWmVAoCQJZSt8GLsY8-2GXO_vqYKeuNdgBs7OD2O6bvwAFUOZgsrtTYkdMdTclVErEDDgnDWhqbEKRNfZBCOkspzW18fZeUUr2YKtqgRg5LujslTIVXYbxST4pWj5PuNdyfHCXF2wMxyhzEQ" />
</form>