Creating forms and implementing validation
ASP.NET Core provides a good infrastructure for preparing forms and submitting, validating, and processing them on the server side. However, it still requires writing some boilerplate and repeating code. ABP Framework simplifies working with forms by providing tag helpers and automating validation and localization wherever possible. Let's begin with how to render form elements using ABP's tag helpers.
Rendering form elements
The abp-input
tag helper is used to render an appropriate HTML input element for a given property. It is better to show its usage in a complete example.
Let's assume that we need to build a form to create a new movie entity and have created a new Razor Page called CreateMovie.cshtml
. First, let's look at the code-behind file:
public class CreateMovieModel : AbpPageModel { [BindProperty] public MovieViewModel Movie { get; set; } ...