Back to Devexpress

DxUpload.AllowCancel Property

blazor-devexpress-dot-blazor-dot-dxupload-2fa847e4.md

latest3.2 KB
Original Source

DxUpload.AllowCancel Property

Specifies whether users can cancel file upload.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(true)]
[Parameter]
public bool AllowCancel { get; set; }

Property Value

TypeDefaultDescription
Booleantrue

true to allow users to cancel file upload; otherwise, false.

|

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. If multiple files are uploaded at once, users can click the common cancel button to cancel upload of all files.

To cancel the file upload in code, use the following methods:

Users can then reload the file whose upload was canceled. This action raises the FileReloaded event.

To reload the file(s) in code, use the following methods:

Set the AllowCancel property to false to hide the cancel button during the upload process.

razor
<DxUpload Name="myFile" UploadUrl="https://localhost:10000/api/Upload/Upload/"
          AllowCancel="false">
</DxUpload>
csharp
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BlazorDemo.AspNetCoreHost;
[Route("api/[controller]")]
[ApiController]
public class UploadController : ControllerBase {
    [HttpPost("[action]")]
    public ActionResult Upload(IFormFile myFile) {
        try {
            // Write code that saves the 'myFile' file.
            // Don't rely on or trust the FileName property without validation.
        } catch {
            return BadRequest();
        }
        return Ok();
    }
}

See Also

DxUpload Class

DxUpload Members

DevExpress.Blazor Namespace