- Home
- .NET code examples
- Download a Blazor WebAssembly button onclick event example
Download a Blazor WebAssembly button onclick event example
Download the code example for a Blazor WebAssembly button onclick event example.
The Blazor Wasm application sets up a button onclick event and is activated by a call method. This is beneficial if your onclick event is not working.
C# coding challenges
It also shows how to use the [Parameter]
attribute to set up an onclick event in a child Razor component. By setting up a EventCallback type property and using the parameter attribute, we can pass an onclick event to another Razor component.
In-addition, onmouseover and onmouseout are other Blazor events that the application uses.
There is also an example for using asynchronous methods. Blazor Wasm's async methods work by calling the async keyword, returning a Task type and using the await keyword to wait for a response before continuing with the method. This allows us to use the onclick event using async.
Software
This is the software that will need to be installed onto your machine.
- Visual Studio 2019. Version 16.10.3 or above (may work with lower versions). It will work with the free community version.
- .NET 5.0 SDK, or above.
Get The Application Working
These are the steps to get the application working.
- Fill out the code example form. We will send you an email where you can download the code example.
You are now ready to go.
Open the Project in Visual Studio
Open up RoundTheCode.BlazorOnClick.sln
in Visual Studio.
Start the project in Visual Studio.
Hit https://localhost:4500
, and the application will run.
More Information
Watch our YouTube tutorial, where we go about using the button onclick event to create and delete a record from a list.
We also explore other events, and demonstrate how to use asynchronous methods in Blazor.
In addition, read our article on How to use the button onclick event in Blazor WebAssembly, which will discuss how we went about building the Blazor Wasm application.