34 Using Blazor Server, part 2

 

This chapter covers

  • Composing elements to combine Blazor components
  • Configuring components using attributes
  • Displaying child content and creating templates
  • Managing connection errors and application errors

In this chapter, I continue to describe Blazor Server, focusing on the way that Razor Components can be used together to create more complex features. Table 34.1 provides a guide to the chapter.

Table 34.1 Chapter guide (view table figure)

Problem

Solution

Listing

Creating complex features using Blazor

Combine components to reduce duplication.

3, 4

Configuring a component

Use the Parameter attribute to receive a value from an attribute.

5–10

Defining custom events and bindings

Use EventCallbacks to receive the handler for the event and follow the convention to create bindings.

11–14

Displaying child content in a component

Use a RenderFragment named ChildContent.

15, 16

Creating templates

Use named RenderFragment properties.

17, 25

Distributing configuration settings widely

Use a cascading parameter.

26, 27

Responding to connection errors

Use the connection element and classes.

28, 29

Responding to unhandled errors

Use the error element and classes or define an error boundary.

30–35

34.1 Preparing for this chapter

This chapter uses the Advanced project from chapter 33. No changes are required to prepare for this chapter.

34.2 Combining components

34.2.1 Configuring components with attributes

34.2.2 Creating custom events and bindings

34.3 Displaying child content in a component

34.3.1 Creating template components

34.3.2 Using generic type parameters in template components

34.3.3 Cascading parameters

34.4 Handling errors

34.4.1 Handling connection errors

34.4.2 Handling uncaught application errors

34.4.3 Using error boundaries

Summary