Trouble with @onclick events in Blazor Server
I'm trying to get the hang of blazor server (.NET 8). Adding an '@onclick' event to any component in my project causes a slew of rendering errors in the console, making them dispose themselves and not show up on the page. Web searches are pointing me towards changing the render mode, but that isn't giving me different results so far. Real appreciated if anyone could point me in the right direction.
2 Replies
hello
can you show me your code so maybe I can identify the cause of your error?
Been trying to rule things out, seems like not every @onclick event causes issues, but specifically components that contain @onclick events which I then nest inside my Main.razor file. The console shows an InvalidCharacterException before that nested component gets disposed, occuring at
Microsoft.AspNetCore.Components.RenderTree.Renderer.InvokeRenderCompletedCallsAfterUpdateDisplayTask
truncated, but the main.razor looks something like this
ChatLog.razor looks something like this, and removing the button events halts the errors