Search⌘ K

Adding new Tasks

Explore how to add new tasks in a Blazor WebAssembly task manager by modifying Index.razor and its code-behind. Understand using PostAsJsonAsync to send task data to the ASP.NET Web API and verify task persistence in SQL Server.

We'll cover the following...

We need to add the ability to add new tasks. We do this as follows:

  1. Open the Index.razor file.
  2. Add the following markup before the @foreach loop:
C++
<div class="d-flex col col-lg-3 mb-4">
<input placeholder="Enter Task" @bind="newTask" />
<button class="btn btn-success"
@onclick="AddTask">Submit
</button>
</div>
  1. Open the TaskManager.Client.Pages/Index.razor.cs
...