Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxUpload.CancelFileUpload(UploadFileInfo) Method

Cancels a specific file’s upload.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void CancelFileUpload(
    UploadFileInfo fileInfo
)

#Parameters

Name Type Description
fileInfo UploadFileInfo

The file whose upload is cancelled.

#Remarks

When file upload is in progress, users can click the cancel button to interrupt file upload. Handle the FileUploadAborted event to respond to this action.

Upload - Cancel File Upload

Use the CancelFileUpload method to cancel a specific file upload in code. The snippet below displays a button that cancels upload of the first file on click.

Razor
<DxUpload UploadMode=UploadMode.OnButtonClick
          SelectedFilesChanged="@SelectedFilesChanged"
          AllowMultiFileUpload="true" 
          @ref="MyUpload" >
</DxUpload>

<DxButton Text="Cancel the First File Upload" Click=OnButtonClick />

@code {
    bool UploadVisible { get; set; } = false;
    IEnumerable<UploadFileInfo> Files { get; set; }
    UploadFileInfo FirstFile { get; set; }
    DxUpload MyUpload { get; set; }

    protected void SelectedFilesChanged(IEnumerable<UploadFileInfo> files) {
        Files = files;
        UploadVisible = files.ToList().Count > 0;

        InvokeAsync(StateHasChanged);
    }

    void OnButtonClick(){
         FirstFile = Files.First();
         MyUpload.CancelFileUpload(FirstFile);
    }
}

To cancel upload of the specified files or all files, use the CancelFilesUpload or CancelAllFilesUpload method, respectively.

To reload the file(s) whose upload was canceled, use the following methods:

See Also