36 Blazor forms and data

 

This chapter covers

  • Using built-in components to create HTML forms
  • Validating form data
  • Responding to form events
  • Using Entity Framework Core with Blazor components
  • Performing CRUD operations
  • Extending Blazor

In this chapter, I describe the features that Blazor provides for dealing with HTML forms, including support for data validation. I describe the built-in components that Blazor provides and show you how they are used. In this chapter, I also explain how the Blazor model can cause unexpected results with Entity Framework Core and show you how to address these issues. I finish the chapter by creating a simple form application for creating, reading, updating, and deleting data (the CRUD operations) and explain how to extend the Blazor form features to improve the user’s experience. Table 36.1 puts the Blazor form features in context.

36.1 Preparing for this chapter

36.1.1 Dropping the database and running the application

36.2 Using the Blazor form components

36.2.1 Creating custom form components

36.2.2 Validating form data

36.2.3 Handling form events

36.3 Using Entity Framework Core with Blazor

36.3.1 Understanding the EF Core context scope issue

36.3.2 Understanding the repeated query issue

36.4 Performing CRUD operations

36.4.1 Creating the list component

36.4.2 Creating the details component

36.4.3 Creating the editor component

36.5 Extending the Blazor form features

36.5.1 Creating a custom validation constraint

36.5.2 Creating a valid-only submit button component

Summary