Skip to main content
A newer version of this page is available. .
Tab

ASPxUploadControl.FilesUploadComplete Event

Occurs after all the selected files have been uploaded to the server.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

public event EventHandler<FilesUploadCompleteEventArgs> FilesUploadComplete

Event Data

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

Property Description
CallbackData Gets or sets a string that contains specific information (if any) to be passed from the server side to the client.
ErrorText Gets or sets the error text to be displayed within the control’s error frame if the file upload fails.

Remarks

File uploads can be initiated by clicking the upload button, in code (using the ASPxClientUploadControl.Upload method), or automatically (on the next round trip to the server, e.g., on a button click or page refresh). Handle the FilesUploadComplete event to perform specific server operations after upload of all the selected files has been completed on the server side. The FilesUploadComplete event occurs after the ASPxUploadControl.FileUploadComplete event for each of the selected files has been raised. To access the uploaded files, use the ASPxUploadControl.UploadedFiles property.

Note

When the ASPxUploadControl.FileUploadMode property is set to the default BeforePageLoad value, a file is uploaded and the request execution is aborted before the Page_Init method is called. Thus, controls are not initialized and not available in the FilesUploadComplete event. Set the ASPxUploadControl.FileUploadMode property to OnPageLoad to rebuild the page hierarchy before the ASPxUploadControl requires it. In this case, control properties are available in the FilesUploadComplete event. For more information see the Page Life Cycle During File Upload topic.

Example

This sample demonstrates how files selected within the ASPxUploadControl can be uploaded via either postback or callback, and how the uploaded files can be saved on the server side by using the FilesUploadComplete event.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxUploadControl;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e){

    }

    protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FilesUploadCompleteEventArgs e){
        // Intentionally pauses server-side processing to demonstrate the Loading Panel or Progress Panel functionality
        System.Threading.Thread.Sleep(2000);

        ASPxUploadControl uploadControl = sender as ASPxUploadControl;

        if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0){
            for (int i = 0; i < uploadControl.UploadedFiles.Length; i++){
                UploadedFile file = uploadControl.UploadedFiles[i];
                if (file.FileName != ""){
                    string fileName = string.Format("{0}{1}", MapPath("~/Images/"), file.FileName);
                    //file.SaveAs(fileName, true);//OnLine Demo Restriction
                }
            }
        }
    }
}
See Also