InputText requires a value for the ‘ValueExpression’ parameter
For me, it was because I was using @bind-value. The v is uppercase. Use @bind-Value
For me, it was because I was using @bind-value. The v is uppercase. Use @bind-Value
You need to call the Delete method properly and make it return Task instead of void: <button onclick=”@(async () => await Delete(person.Id))”>❌</button> @functions { // … async Task Delete(Guid personId) { await this.PersonRepository.Delete(personId); } }
TL;DR This is because of the prerendering mechanism that initializes the component as a part of the host page _Host.cshtml, so that the first http request would result in a host page that comes not only as a script loader of the blazor application, but also with a statically rendered view. Therefore the user could … Read more
The way to do it after release 3.1 of ASP.NET Core seems to be <a href=”” @onclick=”@SomeAction” @onclick:preventDefault />
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
Note: This answer is from December 2018 when an early version of Server-side Blazor was available. Most likely, it is no longer relevant. The poor man’s approach to state is a hinted by @JohnB: Use a scoped service. In server-side Blazor, scoped service as tied to the SignalR connection. This is the closest thing to … Read more
Maybe you can try running your application from command prompt: dotnet watch run debug
More digging on this revealed that there are both non-Blazor specific .NET Core ways to turn on Detailed Errors, and also a Blazor specific approach: The general .NET Core way to turn on Detailed Errors: There are a number of ways to get the detailed errors as discussed in the .NET Core documentation, but I … Read more
I have tried calling StateHasChanged() – instead of InvokeAsync(StateHasChanged) – in a Timer’s Elapsed event, and it works as expected That must have been on WebAssembly. When you try that on Blazor Serverside I would expect an exception. StateHasChanged() checks if it runs on the right thread. The core issue is that the rendering and … Read more
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