-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Blazor client onclick function with parameter #10138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, you can do this with something like that
if you want pass args (UIEventArgs) good luck |
Not quite.. All of these will return the last number (5)
|
wow you are right it's really bad ! I have a workaround which works
but the team have to solve it, it can't stay like that |
Ok so it took me a few minutes to figure it out but here's what I believe is going on. Because you're using a lambda function to define the event, its taking
I think its actually working as intended but its not obvious. |
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments. |
I have altered the counter page to demonstrate. The UI is not refreshed when you hit one of the "Set counter to" buttons. I am using Blazor Server Side Preview 6.. `@page "/counter" CounterCurrent count: @currentCount Click me
` |
@Madunet add <button class="btn btn-primary" @onclick="@(() => test(a))">Set counter to @a</button> |
I needed similar syntax for invoking a method with a parameter and here is what worked for me: Razor: Code: Note: I'm using RC1, which includes some changes necessary as of Preview 9: "Replace Microsoft.AspNetCore.Components.UIEventArgs with System.EventArgs and remove the “UI” prefix from all EventArgs derived" See: https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-9/ |
Adding parameter to a function in Blazor client throws compiler error: Cannot convert from void to string, example:
The text was updated successfully, but these errors were encountered: