// Call a JavaScript function with no parameters and expect a result int result = await JSRuntime.InvokeAsync("myFunction"); // Call a JavaScript function with parameters and expect a result string param1 = "hello"; int param2 = 123; double result = await JSRuntime.InvokeAsync ("myFunction", param1, param2);
// Call a JavaScript function with no result await JSRuntime.InvokeAsyncBoth examples assume that the function "myFunction" is defined in the JavaScript code running in the browser. The IJSRuntime is part of the Microsoft.AspNetCore.Components.WebAssembly.Services package library.("myFunction"); // Call a JavaScript function with parameters and no result string param1 = "hello"; int param2 = 123; await JSRuntime.InvokeAsync ("myFunction", param1, param2);