From the course: Blazor WebAssembly: Building Your First App
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Code blocks - Blazor Tutorial
From the course: Blazor WebAssembly: Building Your First App
Code blocks
- [Instructor] A code block is an important part of a Razor component. It allows you to embed C# code into your component. Using the code block, you can declare variables, classes and methods. It also allows you to override the functionality when a component is initialized. This is important so we can control how the UI looks when it's first loaded and what data should be displayed. A Razor component inherits from this component based abstract class. This has a number of methods that help a Razor component function. Anything marked with a virtual keyword indicates that we can override the method inside the Razor component. We will be looking at an OnInitialized and OnInitializedAsync methods. Looking at the component lifecycle, The OnInitialized is called first. If you have methods that are asynchronous and you need to await them, you can use the OnInitializedAsync method. Both of these methods are called once…
Contents
-
-
-
-
-
(Locked)
Create a Razor component4m 15s
-
(Locked)
Code blocks4m 7s
-
(Locked)
Parameters6m 23s
-
(Locked)
Other directives5m 50s
-
(Locked)
Data binding3m 34s
-
(Locked)
Event handling3m 55s
-
(Locked)
Built-in components5m 44s
-
(Locked)
Challenge: Basic web application4m 27s
-
(Locked)
Solution: Basic web application5m 27s
-
(Locked)
-