How to do it...

Form TagHelpers make it easier for developers to create reusable components inside CSHTML views.

  1. Here is a typical form using the Form TagHelper:
<form asp-area="" asp-controller="Product" asp-action="AddProduct" method="post" asp-antiforgery="true">  <div asp-validation-summary="All"></div>  <div class="form-group">    <label asp-for="Name"></label>    <input type="text" asp-for="Name" />    <span asp-validation-for="Name" class="text-danger"></span>  </div>  <div class="form-group">    <label asp-for="Price"></label>    <input type="text" asp-for="Price" />    <span asp-validation-for="Price" class="text-danger"></span>  </div>  <div class="form-group">    <label asp-for="CategoryName"></label> <select asp-for="CategoryName" asp-items="@Categories.GetCategories()"> ...

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.