Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Web App Call .NET methods from JavaScript not work in .NET 8

$
0
0

My attempts to run a NET call from JS ended in failure.Tried including examples from Microsoft.But adding to the page

@rendermode InteractiveServer

So that the button would work. Causes an error.

Here is the code that worked in .NET 7

async Task Up(){    await JS.InvokeVoidAsync("Crop.responses", DotNetObjectReference.Create(this), Id);   crop2View = "opcity-0";}[JSInvokable]public async void ResponseMethod(string data){    model.Base64 = data;    await UploadServer();    StateHasChanged();}

JS code

var base64data;window.Crop = {            responses: function (component, id) {        resize.result('blob').then(function (blob) {            var reader = new FileReader();            reader.readAsDataURL(blob);            reader.onloadend = async function () {                base64data = reader.result;                var i = document.getElementById('result-'+ id);                var img = document.createElement('img');                img.src = base64data;                i.appendChild(img);                return component.invokeMethodAsync('ResponseMethod', base64data);            }        });    }};

How to call ResponseMethod from JS


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>