I have a method like below. I will like to call a javascript function and return the result in to a variable
private async Task Checker()
{
var result = (await JsRuntime.InvokeVoidAsync("checkNullValues");
}
Here is the javascript function
function checkNullValues() {
return $('.k-grid-container .excelGridCell').length === 0 && $('.k-textbox').length == 0;
}
In the Checker method, I kept getting this error message
"cannot implicitly convert type void to string"
Is it not possible to do this?
I have a method like below. I will like to call a javascript function and return the result in to a variable
private async Task Checker()
{
var result = (await JsRuntime.InvokeVoidAsync("checkNullValues");
}
Here is the javascript function
function checkNullValues() {
return $('.k-grid-container .excelGridCell').length === 0 && $('.k-textbox').length == 0;
}
In the Checker method, I kept getting this error message
"cannot implicitly convert type void to string"
Is it not possible to do this?
Share Improve this question asked Aug 27, 2021 at 20:12 BabaBaba 2,2299 gold badges53 silver badges94 bronze badges1 Answer
Reset to default 5If you expect to receive values from Javascript function using JSInterop, you should use InvokeAsync method instead of InvokeVoidAsync, indicating the datatype expected to retrieve. For example I suppose that you want to receive a bool, so:
private async Task Checker()
{
var result = await JsRuntime.InvokeAsync<bool>("checkNullValues");
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745088489a4610548.html
评论列表(0条)