Call Blazor Function from Javascript

How to call Blazor c# Function from Javascript in Blazor Web Assembly Appliation

October 17, 2020

In this article we will see how to call blazor function from javascript in Blazor WebAssembly Application

Razor Code

To call blazor function from javascript we must have to make it static and JSInvokable

[JSInvokable]
public static void UpdateData(string para1string para2)
{
    //CODE
}

Jquery Code

DotNet.invokeMethodAsync('BlazorApp''UpdateData', para1, para2);
//BlazorApp - Your Application DLL Name
//UpdateData - Function Name [JSInvokable]

Note:

Check how to Update Model data from JSInvokable method here

Post Comments(0)

Leave a reply

Will not be displayed in comment box .

Loading...