Blazor components are reusable UI elements written in C# and HTML (Razor syntax).
Example:
// MyComponent.razor
<h1>Hello, @Name</h1>
@code {
[Parameter]
public string? Name { get; set; }
}
A quick reference guide for Blazor, covering components, data binding, routing, and other essential concepts for building interactive web UIs with C#.
Blazor components are reusable UI elements written in C# and HTML (Razor syntax). Example:
|
Components can receive data through parameters. Use the |
|
Called when the component is initialized, after parameters are set. |
|
Called after the component receives parameters from its parent. |
|
Called after the component has been rendered. Use |
|
Allows you to control when a component should re-render. Return |
|
Called when the component is being disposed. Use this to unsubscribe from events and release resources. |
Blazor uses standard C# event handling. Example:
|
Use |
Displaying data from a C# variable in the UI. Example:
|
Allows updating a C# variable when the UI element changes. Example:
|
|
|
Defines the route for a component, making it accessible via a URL. Example:
|
Use |
Pass data to a component through the URL. Example:
|
Use |
Programmatically navigate between pages using Example:
|
Inject |
Register services in Example:
|
Use |
Inject services into components using the Example:
|
Use |