Blazor Textfield Oninput User Typing Delay

Solution: There is no single solution to your question. The following code is just one approach. Take a look and adapt it to your requirements. The code resets a timer on each keyup, only last timer raises the OnUserFinish event. Remember to dispose timer by implementing IDisposable @using System.Timers; @implements IDisposable; <input type=”text” @bind=”Data” @bind:event=”oninput” … Read more

Embedding a Leaflet map on a Blazor SPA

Note: The sample code below was created and tested in a WebAssembly Blazor App stand alone… An object reference is required for the nonstatic field, method, or property ‘member’ Let’s create the object class, whose object reference will be passed to your JavaScript’s object when initialized. When the user clicks on a location on the … Read more

Blazor component : refresh parent when model is updated from child component

Create a shared service. Subscribe to the service’s RefreshRequested event in the parent and Invoke() from the child. In the parent method call StateHasChanged(); public interface IMyService { event Action RefreshRequested; void CallRequestRefresh(); } public class MyService: IMyService { public event Action RefreshRequested; public void CallRequestRefresh() { RefreshRequested?.Invoke(); } } //child component MyService.CallRequestRefresh(); //parent component … Read more

Get Current User in a Blazor component

There are three possibilities for getting the user in a component (a page is a component): Inject IHttpContextAccessor and from it access HttpContext and then User; need to register IHttpContextAccessor in Startup.ConfigureServices, normally using AddHttpContextAccessor. Edit: according to the Microsoft docs you must not do this for security reasons. Inject an AuthenticationStateProvider property, call GetAuthenticationStateAsync … Read more