How to trigger the upload from a parent component

1 Answer 25 Views
Upload
Holger
Top achievements
Rank 1
Iron
Iron
Holger asked on 19 Apr 2022, 06:13 AM

Hi,

I have the following structure (shortend):

FormComponent.razor:

<UploadBox @ref="@BoxForUpload" />

FormComponent.razor.cs:

public UploadBox BoxForUpload;

public async Task OnSelect(UploadSelectEventArgs args)
{
    BoxForUpload.DoUpload();
}


UploadBox.razor:

<TelerikUpload @ref="@UploadRef" AutoUpload="false"></TelerikUpload>

UploadBox.razor.cs:

[Parameter] public EventCallback<UploadSelectEventArgs> OnSelect { get; set; }

public TelerikUpload UploadRef { get; set; }

public void DoUpload()
{
    UploadRef.UploadFiles();
}

 

If I set AutoUpload to true, the upload works.

But if I set AutoUpload to false, the OnSelect will be triggered, but the upload do not work (no file receives the upload-api) and there are no errors in the console. How can I trigger the upload from the FormComponent?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 21 Apr 2022, 05:55 AM

Hi Holger,

Use generic Blazor technique - see StackOverflow.

Regards,
Dimo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Upload
Asked by
Holger
Top achievements
Rank 1
Iron
Iron
Answers by
Dimo
Telerik team
Share this question
or