Skip to content

Blazor client onclick function with parameter #10138

Closed
@ziodex

Description

@ziodex

Adding parameter to a function in Blazor client throws compiler error: Cannot convert from void to string, example:

<a onclick="@MyFunction">My function</a>

void MyFunction() {
    Console.WriteLine("Works");
}


<a onclick="@MyFunction(1)">My function</a>

void MyFunction(int number) {
    Console.WriteLine("Throws error");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions