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. The first subsection describes the basics of component structure.
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, but you can organize them differently.
By default, pages are assigned a namespace that corresponds to the path...