I am setting Auto to false and excluding the URL, similar to this post .
However, I’m unable to get the OnComplete event to fire. The intent is to use OnComplete and OnChange events from upload, and to handle the processing from a button’s click event. But perhaps I cannot use Upload in this manner?
UPDATE: For my scenario, which leverages ClearFiles(), I can just complete the processing in the button's click handler. I don't need the OnComplete event, therefore, I don't need to call Update(). Not sure if this post will benefit others.
@if (!string.IsNullOrEmpty(statusMessage))
{
<p>Status Message: @statusMessage</p>
}
<RadzenCard Variant="Variant.Outlined">
<RadzenUpload @ref="RadzenUploadComponent"
Auto="false"
Change=@OnChange
Multiple="true"
Complete=@OnComplete
ChooseText="Select Picture Files"
Style="width: 100%"
InputAttributes="@(new Dictionary<string,object>{ { "aria-label", "select file" }})" />
<RadzenButton Text="Upload Files" Click=@OnClickUpload class="rz-mt-4" />
</RadzenCard>
@code {
private string statusMessage = "";
RadzenUpload RadzenUploadComponent;
IEnumerable<Radzen.FileInfo>? filesSelected = new List<Radzen.FileInfo>();
private async void OnClickUpload()
{
foreach (Radzen.FileInfo? fInfo in filesSelected!)
{
// processing files
}
await RadzenUploadComponent.Upload(); // just to ensure the Complete event is triggered.
statusMessage = $"Files were uploaded successfully.";
// StateHasChanged(); // I thought I did not need to call this from an event handler
}
void OnChange(UploadChangeEventArgs args)
{
filesSelected = args.Files;
}
void OnComplete(UploadCompleteEventArgs args) // This not getting called
{
statusMessage = "Files uploaded.";
RadzenUploadComponent.ClearFiles();
}
}