Get EventCallBack result with Multiple Parameter

Hi
I use the RadzenUpload On RadzenDialogservice, how can i get list of files that select and upload in main component

My code is:

In DialogService

<div class="row ml-4 mr-4">
                <RadzenUpload @ref="upload" Auto="false" Multiple="true" Change=@(args => OnChangeUpload(args)) ChooseText="انتخاب فایل" class="w-100" />
            </div>

@code {
[Parameter]
    public EventCallback<(RadzenUpload, IEnumerable<Radzen.FileInfo>)> OnSave { get; set; }
    RadzenUpload upload;
    IEnumerable<FileInfo>? files;

private async Task OnChangeUpload(UploadChangeEventArgs args)
    {
        files = args.Files;        
    }

private async Task SaveInfo()
    {        
        //await upload.Upload();
        await OnSave.InvokeAsync((upload, files));
    }

}




============================



In main component:

private async Task ShowAddNewMentionPanel()
    {
        var callback = EventCallback.Factory.Create<(RadzenUpload, IEnumerable<Radzen.FileInfo>)>("OnSave", arg =>
    {
        AddUpMentioned(arg.Item1, arg.Item2);
    });

        SubProject = await SubProjectRepo.GetSubProjectList();
        ManagerUser = await UserRepo.GetManagerUsersAsync();
        var p = await DialogService.OpenAsync<AddMentionedItem>("New Item",
                           new Dictionary<string, object>() {
                               { "ManagerUser", ManagerUser }, { "meetingId", NewMeetingId }, { "OnSave", callback }, { "mentionedItems", mentionedItems }
                           , { "SubProject", SubProject} },
                           new DialogOptions() { Width = "50%", Height = "50%", Resizable = true, Draggable = false });
    }

private EventCallback AddUpMentioned(RadzenUpload upload, IEnumerable<Radzen.FileInfo> files) => new(null, (Action)(async () =>
    {
        var res = await MeetingRepo.AddUpdateMention(mentionedItems);
        if (res.ResultCode > 0)
        {
            if (files != null)
            {
                if (files.Count() > 0)
                {
                    foreach (var item in files)
                    {
                        var result = await MentionRepo.UploadAttachment(res.ResultCode, item.Name);
                    }
                    upload.Url = $"api/mentioned/UploadMentionAttachment/{res.ResultCode}";
                    await upload.Upload();
                }
            }
            await JSRuntime.InvokeVoidAsync("ShowToast", 0, "Success!", "");
        }
        await InvokeAsync(StateHasChanged);
    }));

My component work correctly when show normaly and out of DialogService

Hi @mojtabaie,

You cannot do that. You can't upload the files without the RadzenUpload component itself. You have to upload them from the dialog itself.

This is resolved

var callback = EventCallback.Factory.Create<UploadParameterModel>(this, AddUpMentioned);

private async Task AddUpMentioned(UploadParameterModel model)
    {
        var res = await MeetingRepo.AddUpdateMention(mentionedItems);
        if (res.ResultCode > 0)
        {
            if (model.MyFile != null)
            {
                if (model.MyFile.Count() > 0)
                {
                    foreach (var item in model.MyFile)
                    {
                        var result = await MentionRepo.UploadAttachment(res.ResultCode, item.Name);
                    }
                    model.Upload.Url = $"api/mentioned/UploadMentionAttachment/{res.ResultCode}";
                    model.Upload.Upload();
                }
            }
            await JSRuntime.InvokeVoidAsync("ShowToast", 0, "Success!.", "");
        }
        await InvokeAsync(StateHasChanged);
    }