Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Server Side Blazor Component in .net 8, @onclick event not firing

$
0
0

In Blazor Server in .net 7 I can do this in a Page.blazor:

@message

<button class="btn btn-primary mt-2 btn-block" @onclick="SendMessage">Send Message</button>@code {    public string message { get; set; }    private async Task SendMessage()    {        message = "Hello";    }}

When you click the button it outputs "Hello" on the page.

However, in .net 8 in a "Blazor Web App" (Auto, Server mixed with Web Assembly) in a Page.blazor on the server side, this button doesn't work.

Buttons in an EditForm do work but I don't want to use that, I just want clicking a button to fire an event.

Why doesn't this work in .net 8 and how can I do this?

Thanks


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>