Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor InputFile onchange doesn't trigger the method

@page "/fileup"
<h3>FileUp</h3>
<InputFile OnChange="@UploadedExcel" accept=".xlsx" />
@code {
    public async Task UploadedExcel(InputFileChangeEventArgs e)
    {
        Console.WriteLine("Hello");
        
    }
}

The code should be basic enough but it doesn't trigger the task down below when I upload a file. Am I missing something?

I have tried a few different things including changing to multifile and all. I have another page with full code block that I don't wanna sahre because of many unrelated things. But this on itself should work right? Network

I was missing the @rendermode InteractiveAuto at the top of the page. After adding it, it triggered my method.

like image 395
yunus emre kaya Avatar asked Jul 21 '26 05:07

yunus emre kaya


1 Answers

In my case the file upload fired the event after adding this code to the top of the page

@rendermode InteractiveServer

this option means you use Interactive server-side rendering (interactive SSR) with the razor page. I am using .net 8 which uses static server-side rendering by default.

like image 115
Wael Galal El Deen Avatar answered Jul 23 '26 09:07

Wael Galal El Deen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!