Hi,
there is a pretty good solution for this written by the 'blazor master' himself - Steve Sanderson.
Read his post for a detailed despriction:
https://blog.stevensanderson.com/2019/09/13/blazor-inputfile/
Apart from that, there will be in built in component for that in .net 5.
https://docs.microsoft.com/en-us/aspnet/core/blazor/file-uploads?view=aspnetcore-5.0
Thank you for sharing the solution with the community, Tom. It's good to hear you solved this!
Regards,
Marin Bratanov
Progress Telerik
Hi Marin,
Update on my UI refresh issue with the DemoFileSelector inside a Telerik Window.
It was not due to StateHasChanged, I already was handling to bubble up StateHasChanged for all the components in the tree.
However, my issue was caused because of the EditForm and EditContext I was using. I was assigning a new object instance to the model of the EditContext which caused the UI not to refresh consistently anymore (validations were off as well by the way).
Everything started working when I changed to assigning the property values of the model instead of assigning a new object.
Thanks for your response though.
protected override void OnInitialized()
Hi Tom,
Could you check the following KB for an example that shows how you can raise an event from the window in the context of the rest of the content to invoke StateHasChanged: https://docs.telerik.com/blazor-ui/knowledge-base/window-does-not-update-parent? The window does not render in the same place as its declaration, so its shows up above all else, and that means that events and updates inside don't always re-render the components around it.
Regards,
Marin Bratanov
Progress Telerik
Hi,
Using DemoFileSelector within a Telerik Window does not completely work. In the sense that the the filename once you have selected a file does not get updated to the UI. Tried myself by adding StateHasChanged, but still UI does not get updated.
Any idea how to get this to work?
Thanks,
Tom
Hi,
An Upload and FileSelect component are fundamentally different in Blazor. At this point, we have an Upload component whose demos are here: https://demos.telerik.com/blazor-ui/upload/overview.
You can find an offline version in your installation:
In those demos, you can find the example of a FileSelect we made for the document processing demos.
Regards,
Marin Bratanov
Progress Telerik
In the meantime, you can find a sample implementation in our demos - the ~/Shared/DemoFileSelector.razor component which also uses the JS Interop code from ~/wwwroot/js/download-upload-files.js and the C# from ~/DocumentProcessing/Common/DemoFileExporter.cs and ~/DocumentProcessing/Common/UploadedFileDetails.cs.
Regards,
Marin Bratanov
Progress Telerik