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

Why is @foreach with @onclick not working? [closed]

$
0
0

I’m trying to dynamically generate buttons in a Blazor component using a @foreach loop. Each button should trigger a method with the corresponding item as a parameter

@foreach (var item in items){<button @onclick="() => HandleClick(item)">Click Me</button>}void HandleClick(object item){    Console.WriteLine(item);}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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