SharpRuneOpen playground

Blazor WebAssembly

Build interactive web apps from Razor components in C#, compile them on your iPhone or iPad, and run them in Preview on .NET.

  • 12 lessons
  • 5 h 20 min
  • Blazor WebAssembly projects + portable .NET 9 companion practice

Components and Razor

4 lessons · 1 h 50 min
  1. 01A component is a C# class with markupWrite a Razor component with expressions, @code, @foreach and @if, and see how the file becomes one C# class.25 min
  2. 02Parameters and child contentPass data into components with [Parameter], require it with [EditorRequired], and let a parent supply markup through ChildContent and RenderFragment<T> templates.25 min
  3. 03Events, state and re-renderingHandle clicks with methods, lambdas and async handlers, raise EventCallback from child to parent, and know when StateHasChanged is needed.30 min
  4. 04Two-way bindingBind inputs, selects and checkboxes with @bind, choose the event, run code after a change, take over with @bind:get/@bind:set, and see how numbers and dates are parsed.30 min

Pages and app structure

4 lessons · 1 h 45 min
  1. 05Routing and route parametersGive pages addresses with @page templates, read route and query values, and move between pages with NavLink and NavigationManager.25 min
  2. 06Layouts and component-scoped CSSWrap pages in shared and nested layouts, and keep each component's styles inside it with .razor.css files and ::deep.25 min
  3. 07Services and dependency injectionRegister services in Program.cs, inject them into components through interfaces, and see how singleton, scoped and transient lifetimes behave in Blazor WebAssembly.25 min
  4. 08The component lifecycleFollow SetParametersAsync, OnInitialized, OnParametersSet, OnAfterRender, ShouldRender and disposal in a page that is reused between routes.30 min

Data, forms and the browser

4 lessons · 1 h 45 min
  1. 09Forms and validationBuild a form with EditForm, the Input components and DataAnnotations rules, and choose between OnValidSubmit and OnSubmit.25 min
  2. 10Loading JSON with HttpClientLoad a JSON file from wwwroot with HttpClient and GetFromJsonAsync, and show loading, empty, error and cancelled states.25 min
  3. 11Calling JavaScriptCall JavaScript from C# with IJSRuntime, load a JS module, and let JavaScript call back into a component through DotNetObjectReference.30 min
  4. 12Sharing state across componentsShare data between components with a cascading value and with a state container service that raises an OnChange event.25 min