JavaScript Interop in Blazor: Call JS from C# and C# from JS

Blazor JavaScript interop featured card: the C# call InvokeAsync formatUsd 18.40 goes through Checkout.razor.js and comes back as $18.40

Blazor JavaScript interop runs both ways. From C#, inject IJSRuntime and await InvokeVoidAsync (no result) or InvokeAsync<T> (a result). From JavaScript, call a C# method marked [JSInvokable] with DotNet.invokeMethodAsync. The catch is timing: there’s no browser during prerendering, so JS calls belong in OnAfterRenderAsync. I ran every pattern below on .NET 10, in one checkout … Read more >>

Blazor Component Lifecycle: The Real Call Order in .NET 10

Blazor component lifecycle featured card: a table of the real call order logged by the OrderBoard page, a Static prerender pass then a Server pass

A pizza shop in Chicago’s Wicker Park wanted a live order board in Blazor. My first version hit the database twice on every visit, and its 30-second refresh timer kept firing after the cashier left the page. Both bugs came from the Blazor component lifecycle. Quick answer: load data in OnInitializedAsync with [PersistentState], start timers … Read more >>

Blazor Forms and Validation with EditForm (.NET 10)

Blazor form validation featured card: C# code that runs Validator.TryValidateObject on a Runner model and prints The FullName field is required and an email error

Picture the sign-up page for a Thanksgiving 5K in Austin. Most bad entries last year were blank emails, typos like “jenna.morales@” and kids under the 14+ age limit. Blazor form validation stops all three before your code runs: an EditForm, data annotation attributes on the model and a DataAnnotationsValidator. We’ll build that form on .NET … Read more >>

Blazor Components and Parameters (with Examples) in .NET 10

Blazor components featured card: a ProductCard child sends 2 x Two-Person Tent through EventCallback to the parent order list, Subtotal: $477.94 (4 items)

Say you run the web store for a Portland outdoor gear shop. The product page repeats the same card markup for six items, and every price fix means editing six copies. Blazor components fix that: you write the card once as a .razor file, pass each product in with [Parameter] properties, and send clicks back … Read more >>

Blazor QuickGrid Tutorial: Sorting, Filtering and Paging (.NET 10)

Blazor QuickGrid featured card: an orders grid sorted by Total descending with $2,416.01 on top and the Paginator text 200 items Page 1 of 20

Say the sales manager at a Dallas furniture store wants this year’s 200 orders on one screen, sorted by total, searchable by customer and ten rows a page. In Web Forms you’d drag in a GridView. Blazor doesn’t have one. The built-in answer is Blazor QuickGrid, Microsoft’s free grid component. Give it an IQueryable, mark … Read more >>