Free tools Windows power users keep installed
One-click scans. No signup required.
To make a Blazor task tracker interactive, connect each control to component state: bind the title field, handle the form submission to add a task, and use event handlers to complete or remove tasks. Blazor then renders the list from that updated state. The example below keeps tasks in memory; it demonstrates the interaction loop, not storage across reloads. It follows Microsoft’s ASP.NET Core 10.0 todo-list tutorial, last updated November 11, 2025: Build a Blazor todo list app.
What makes a Blazor task tracker interactive?
A visible button or text box is not interactive merely because it appears in the page. The component needs a path from the browser action to .NET logic and back to rendered markup:
- The user types or clicks.
- A binding or event handler receives the change.
- Component state changes, such as the task title or task collection.
- Blazor renders the component using the current state.
For a small tracker, keep the task collection in the component and make the markup display that collection. An add handler that changes some other variable, without changing the displayed collection, will not add a row to the visible list.
Build a single-component task tracker
This illustrative Razor component holds tasks in memory. Its controls add a task, toggle completion, and remove a task. Put the component in a routable page or another component in your app. In a Blazor Web App, also ensure it is rendered interactively, as covered below.
#1 Best Overall
@page "/tasks"
<h1>Task tracker</h1>
<form @onsubmit="AddTask" @onsubmit:preventDefault>
<label for="task-title">Task title</label>
<input id="task-title" @bind="newTitle" />
<button type="submit">Add task</button>
</form>
@if (tasks.Count == 0)
{
<p>No tasks yet. Add one above.</p>
}
else
{
<ul>
@foreach (var task in tasks)
{
<li @key="task.Id">
<input type="checkbox"
checked="@task.IsComplete"
@onchange="() => ToggleTask(task)" />
<span>@(task.IsComplete ? $"Completed: {task.Title}" : task.Title)</span>
<button type="button" @onclick="() => RemoveTask(task)">Remove</button>
</li>
}
</ul>
}
@code {
private string newTitle = string.Empty;
private readonly List<TaskItem> tasks = new();
private int nextId = 1;
private void AddTask()
{
var title = newTitle.Trim();
if (title.Length == 0)
{
return;
}
tasks.Add(new TaskItem(nextId++, title));
newTitle = string.Empty;
}
private void ToggleTask(TaskItem task)
{
task.IsComplete = !task.IsComplete;
}
private void RemoveTask(TaskItem task)
{
tasks.Remove(task);
}
private sealed class TaskItem(int id, string title)
{
public int Id { get; } = id;
public string Title { get; } = title;
public bool IsComplete { get; set; }
}
}
How task entry works
@bind="newTitle" connects the input value to the component field. The form’s @onsubmit calls AddTask; @onsubmit:preventDefault prevents the browser’s normal form navigation so the Blazor handler can process the submission. The handler trims whitespace, ignores an empty title, appends a task to the collection used by the list, and clears the field.
HTML element binding uses the change event by default, which generally updates the bound value when the user commits the edit, often by leaving the field. If the component needs the value to update on every keystroke—for example, for immediate filtering—use @bind:event="oninput". Choose that timing when the behavior needs it rather than automatically: Microsoft’s Blazor data-binding guidance.
How completion and removal work
Each row is rendered from tasks. The checkbox’s @onchange and the remove button’s @onclick call handlers for that row’s task. Those handlers update the model or collection; the markup then reflects its current state. @key helps Blazor associate each rendered row with its task as the collection changes. For event-handler behavior and callback patterns, see Microsoft’s event-handling reference.
Make sure the page has an interactive render mode
In a Blazor Web App, static server-side rendering can produce the page’s HTML without enabling client-side UI events. Microsoft notes: “When using a Blazor Web App, most of the Blazor documentation example components require interactivity to function and demonstrate the concepts covered by the articles.” See the Razor components documentation and render modes reference.
Rank #3
Choose an interactive render mode at the app or component level, according to the app’s design. Microsoft’s render-mode reference explains the available choices and how to apply them. If a button appears but does nothing, first check whether the page is only statically rendered. A component’s event attributes alone do not make a static page interactive.
Use validation when task entry needs more than a simple check
The example rejects a blank title in its handler, which is enough to illustrate the interaction loop but gives no field-level validation message. For structured validation, use a model with Blazor’s form components and validation support, such as EditForm with a validator and validation message. The Blazor forms overview describes the form and validation approach.
Rank #4
Validation of form input and persistence are separate concerns. This component does not save tasks to a database or retain them after the component is discarded or the page is reloaded. Add a storage service or other persistence layer if the app needs durable tasks; the UI example by itself makes no such guarantee.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Keep state flow clear as the tracker grows
A single component is a useful starting point because the input, handlers, and rendered list all use the same state. If rows or the entry form move into child components, pass values through parameters and report changes with callbacks such as EventCallback<T>. Avoid directly mutating a child component’s parameter: Microsoft’s data-binding guidance recommends binding and callback patterns so changes flow through the owning component.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Keep handlers synchronous when their work is synchronous, as in this example. If a future handler awaits an API or storage operation, make it asynchronous and await that work rather than hiding it behind an untracked operation. The event-handling reference documents asynchronous handler patterns.
Quick Recap
Troubleshoot a button or task list that does not respond
- Nothing happens on click: Confirm the page or component has an interactive render mode, rather than static-only rendering.
- The form navigates or refreshes: Handle its submit event with
@onsubmitand prevent the browser’s default submission when appropriate. - The input value seems stale: Check whether default
change-event timing is suitable, or whether the interaction needs@bind:event="oninput". - The list does not change: Verify the handler modifies the same collection or task model that the markup renders.
- A child component’s value reverts or behaves unexpectedly: Use a parameter plus a change callback or the component binding pattern instead of mutating the parameter directly.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




