Blazor pages and components
In this section, you will learn the basics of Blazor components, how to define a component, its structure, how to attach events to HTML tags, how to define their attributes, and how to use other components inside your components. We have organized all content into different subsections:
- Component structure
- Templates and cascading parameters
- Error handling
- Events
- Bindings
- How Blazor updates HTML
- Component lifecycle
Component structure
Components are defined in files with a .razor
extension. Once compiled, they become classes that inherit from ComponentBase
. Like all other Visual Studio project elements, Blazor components are available through the Add New Item menu. Usually, components to be used as pages are defined in the Pages
folder, or in its subfolders, while other components are organized in different folders. Default Blazor projects add all their non-page components inside the Shared
folder...