Blazor CheatSheet
Blazor CheatSheet
BLAZOR
Cheat Sheet
ez zy l e a r n i n g . n e t
What is Blazor?
Blazor Cheat Sheet Blazor is a free, open-source, single-page apps (SPA) development framework that
enables developers to build interactive web apps using C# on both servers as well
as client-side. Blazor does not require any plugin to be installed on the client to
execute the C#/.NET code inside a browser. It executes the .NET code using
WebAssembly which is a web standard supported by all major browsers. Blazor
Why Blazor? can also run .NET code and build UI on the server and transfer only the updated
DOM to clients over SignalR connections.
1. We can create rich interactive web apps using C#
instead of JavaScript.
2. We can share server-side and client-side app logic
written in .NET.
3. We can render the UI from server as HTML and CSS for
wide browser support, including mobile browsers.
4. We can run web apps on the clients in offline mode
using WebAssembly.
5. We can integrate with modern hosting platforms, such
as Docker.
6. We can leverage the existing .NET ecosystem of .NET
libraries.
7. We can enjoy the benefit of .NET's performance,
reliability, and security.
8. We can stay productive with Visual Studio on Windows,
Linux, and macOS
Google Chrome, including Android Latest Version Mozilla Firefox Latest Version
What is WebAssembly?
WebAssembly (sometimes abbreviated Wasm) is a portable binary format (low-level instructions set) designed to run on any host capable of interpreting those
instructions. The main goal of WebAssembly is to allow developers to build high-performance web apps but the format is designed to be executed and integrated
into other environments as well. WebAssembly is currently supported by all major browsers such as Chrome, Chrome for Android, Edge, Firefox, Safari, Opera, and
many more.
Blazor Hosting Models
The Blazor component model is the core of Blazor and it is designed in such a way that it keeps both calculating the UI changes and rendering the UI separate from
each other. This is why the basic component model doesn’t change no matter what method you are using to render your apps. There are two main hosting models
available at the moment.
Directive Description
@attributes Allows a component to render non-declared attributes.
@bind Allows a component to use data binding features.
@bind:format Used to format data bound DateTime into string.
@bind-{PROPERTY} Used to bind properties of other components.
@on{EVENT} Provides event handling features for components.
@on{EVENT}:preventDefault Prevents the default action for the event.
@on{EVENT}:stopPropagation Stops event propagation for the event.
@key Causes the components diffing algorithm to guarantee preservation of elements or components based on the
key's value.
@ref Provide a way to reference a component instance so that you can issue commands to that instance.
@typeparam Declares a generic type parameter for the generated component class.
Server: Scoped
NavigationManager WebAssembly: Singleton Contains helpers for working with URIs and navigation state.
Server: Scoped
Blazor Form Components
Member Description
Uri Gets the current absolute URI.
LocationChanged An event that fires when the navigation location has changed.
Blazor Events
Component Description
App The root component of the app that sets up client-side routing using the Router component
Router Enables routing to Razor components in a Blazor app
Found Gets or sets the content to display when a match is found for the requested route.
NotFound Gets or sets the content to display when no match is found for the requested route.
Navigating Get or sets the content to display when asynchronous navigation is in progress.
NavMenu The default NavMenu component generates the bootstrap navigation bar.
NavLink Renders an anchor tag, automatically toggling its 'active' class based on whether its 'href' matches the current URI.
LayoutView Displays the specified content inside the specified layout and any further nested layouts.
MainLayout The MainLayout component is the app's default layout component created from Blazor project template.
CascadingValue Provides a cascading value to all descendant components.
Virtualize Provides functionality for rendering a virtualized list of items.
Authentication Handles remote authentication operations
AuthorizeView Selectively displays UI content depending on whether the user is authorized.
Authorized The content that will be displayed if the user is authorized.
NotAuthorized The content that will be displayed if the user is not authorized.
Authorizing The content that will be displayed while asynchronous authorization is in progress.
ezzylearning.net
An online tutorial website that provides a comprehensive array of tutorials on topics ranging from classic Windows
based Application development to the latest in ASP.NET Core, Blazor, ASP.NET MVC, AngularJS, C# and many more.