Back to Devexpress

ASPxClientUploadControl.FilesUploadComplete Event

aspnet-js-aspxclientuploadcontrol-e1af27f3.md

latest4.0 KB
Original Source

ASPxClientUploadControl.FilesUploadComplete Event

Occurs on the client after upload of all selected files has been completed.

Declaration

ts
FilesUploadComplete: ASPxClientEvent<ASPxClientUploadControlFilesUploadCompleteEventHandler<ASPxClientUploadControl>>

Event Data

The FilesUploadComplete event's data class is ASPxClientUploadControlFilesUploadCompleteEventArgs. The following properties provide information specific to this event:

PropertyDescription
callbackDataGets a string that contains specific information (if any) passed from the server side for further client processing.
errorTextGets the error text to be displayed within the upload control’s error frame.

Remarks

Write the FilesUploadComplete event handler to perform specific client actions after all selected files have been uploaded to a server.

The FilesUploadComplete event is generated after the ASPxClientUploadControl.FileUploadComplete events related to all uploaded files have been fired.

Example

A full example is available at the ASPxUploadControl - Upload and Submit online demo.

aspx
<dx:ASPxUploadControl runat="server" ID="DocumentsUploadControl" ClientInstanceName="DocumentsUploadControl" ...>
    <AdvancedModeSettings EnableMultiSelect="true" EnableDragAndDrop="true" ExternalDropZoneID="dropZone" />
    <ValidationSettings  
        AllowedFileExtensions=".rtf, .pdf, .doc, .docx, .odt, .txt, .xls, .xlsx, .ods, .ppt, .pptx, .odp, .jpe, .jpeg, .jpg, .gif, .png"
        MaxFileSize="4194304">
    </ValidationSettings>
    <ClientSideEvents
        FileUploadComplete="onFileUploadComplete"
        FilesUploadComplete="onFilesUploadComplete"
        FilesUploadStart="onFileUploadStart" />
        ...
</dx:ASPxUploadControl>
js
function onFileUploadComplete(s, e) {
    var callbackData = e.callbackData.split("|"),
        uploadedFileName = callbackData[0],
        isSubmissionExpired = callbackData[1] === "True";
    uploadedFiles.push(uploadedFileName);
    if(e.errorText.length > 0 || !e.isValid)
        uploadErrorOccurred = true;
    if(isSubmissionExpired && UploadedFilesTokenBox.GetText().length > 0) {
        var removedAfterTimeoutFiles = UploadedFilesTokenBox.GetTokenCollection().join("\n");
        alert("The following files have been removed from the server due to the defined 5 minute timeout: \n\n" + removedAfterTimeoutFiles);
        UploadedFilesTokenBox.ClearTokenCollection();
    }
}
function onFilesUploadComplete(s, e) {
    uploadInProgress = false;
    for(var i = 0; i < uploadedFiles.length; i++)
        UploadedFilesTokenBox.AddToken(uploadedFiles[i]);
    updateTokenBoxVisibility();
    uploadedFiles = [];
    if(submitInitiated) {
        SubmitButton.SetEnabled(true);
        SubmitButton.DoClick();
    }
}
function onFileUploadStart(s, e) {
    uploadInProgress = true;
    uploadErrorOccurred = false;
    UploadedFilesTokenBox.SetIsValid(true);
}

Online Demos

See Also

FileUploadComplete

Page Life Cycle During File Upload

ASPxClientUploadControl Class

ASPxClientUploadControl Members