How to Use Code Behind for Blazor Components | 2 Solutions
Usually, when we see Blazor components, the C# code handling the interaction for the component template is placed below the template within the same .razor file.
However, there are other ways to implement Blazor components. I will show two alternative approaches to splitting the template and the C# code into separate files.
00:00 Introduction
00:30 Reasons for Separating Code and Template
02:18 The Code-Behind Solution
04:02 Dependency Injection in Code-Behind
05:42 Inheriting from ComponentBase
07:26 Conclusion
🔥 C#/.NET Bootcamp: The Fundamentals & more (Code FRIENDS10 for 10% OFF)*
https://claudiobernasconi.ch/dotnet-course
📌 .NET Developer Roadmap
https://claudiobernasconi.ch/learn-dotnet
📌 YouTube Playlists:
The FREE Blazor Crash Course: https://www.youtube.com/watch?v=89Klc6WHElw&list=PLwISgxnkpZGL_LhTQCWwp-WCzupv7lcp0
C# Programming: https://www.youtube.com/watch?v=dKBuvdGsYYc&list=PLwISgxnkpZGIrkQGwOj6kKXLT8CAp9Gct
✅ SUBSCRIBE FOR MORE VIDEOS
Subscribe: 🔔 https://claudiobernasconi.ch/Subscribe
🚀 CONNECT & SUPPORT
Twitter: https://twitter.com/CHBernasconiC
Blog: https://claudiobernasconi.ch
Newsletter: https://claudiobernasconi.ch/newsletter
* Affiliate Link: I earn a small commission at no additional cost