Replace <InputFile> with <FluentInputFile>, got "Microsoft.JSInterop.JSException: Cannot read properties of undefined" #2375
-
I have tried the [Microsoft Upload image preview example] (https://learn.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-8.0#upload-image-preview) and it works fine. The example code below The blazor code
The javascript
The example uses blazor built-in "InputFile" component and can get the file via "inputElem.files[0]" in javascript. My question is if using "[FluentInputFile] (https://www.fluentui-blazor.net/InputFile)" then "inputElem.files[0]" failed with below message
It seems you cannot use inputElem.files[0] in javascript if using "FluentInputFile". But what is the equivalent? From the debug screen (as attached), if using the blazor built-in component "InputFile", I can see the "inputElem.files". If using "FluentInputFile", not the "inputElem.files". Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Can you use I think that the |
Beta Was this translation helpful? Give feedback.
Can you use
<FluentInputFile Id="my-id"
and get a reference to the InputFile element using the JavaScriptdocument.getElementById('my-id')
I think that the
@ref
doesn't reference the InputFile element.