🎓 All Courses | 📚 Blazor WASM Syllabus
Stickipedia University
📋 Study this course on TaskLoco

Blazor uses event directives to wire up user interactions — clicks, key presses, form submissions — to C# methods.

Basic Click Event

<button @onclick="HandleClick">Click Me</button>

@code {
    private void HandleClick()
    {
        Console.WriteLine("Button clicked!");
    }
}

Inline Lambda

<button @onclick="() => count++">Increment</button>

Accessing Event Arguments

<input @onkeydown="HandleKey" />

@code {
    private void HandleKey(KeyboardEventArgs e)
    {
        if (e.Key == "Enter") SubmitForm();
    }
}

Common Event Directives

  • @onclick — mouse click
  • @onchange — input value changed
  • @oninput — every keystroke
  • @onsubmit — form submission
  • @onkeydown / @onkeyup — keyboard events
  • @onfocus / @onblur — focus events

Async Handlers

private async Task LoadDataAsync()
{
    data = await Http.GetFromJsonAsync<List<Item>>("/api/items");
}

YouTube • Top 10
Blazor WASM: Handling Events
Tap to Watch ›
📸
Google Images • Top 10
Blazor WASM: Handling Events
Tap to View ›

Reference:

Wikipedia: Event-Driven Programming

image for linkhttps://en.wikipedia.org/wiki/Event-driven_programming

📚 Blazor WASM — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT