Tab

ASPxUploadControl.FileUploadComplete Event

Occurs after a file has been uploaded to the server.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public event EventHandler<FileUploadCompleteEventArgs> FileUploadComplete

Event Data

The FileUploadComplete event's data class is FileUploadCompleteEventArgs. 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.
IsValid Gets or sets a value specifying whether the uploaded file passes validation.
UploadedFile Gets the uploaded file object related to the event.

Remarks

The FileUploadComplete event occurs when uploading the specified file has been completed on the server side, initiated either manually (by a call to the ASPxClientUploadControl.Upload method) or automatically (on the next round trip to the server, as on a button click or page refresh). Handle the FileUploadComplete event to perform specific server operations after the specified file has been uploaded.

The FileUploadComplete event allows you to verify whether the uploaded file passes the required validation criteria (if any are defined by using the ASPxUploadControl.ValidationSettings property or writing custom code logic), and save the file to a specific server location (using, for instance, the UploadedFile.SaveAs method).

Note that if the file upload was initiated by the client ASPxClientUploadControl.Upload method, and the FileUploadComplete event is handled during callback processing, you can use the event's FileUploadCompleteEventArgs.CallbackData property to pass any additional information to the client for further processing in a handler of the ASPxClientUploadControl.FileUploadComplete client event.

NOTE

The ASPxUploadControl aborts request execution when a file is uploaded, so some your code cannot be executed. This behavior is by design and depends on the ASPxUploadControl.FileUploadMode property value and control creation approach (markup or runtime). See the Page Life Cycle During File Upload topic for more details.

Examples

The following sample code demonstrates how to save the file specified within the ASPxUploadControl on the client. Before file saving, the FileUploadCompleteEventArgs.IsValid property is tested to verify whether the file passes the validation criteria defined via the ASPxUploadControl.ValidationSettings property. Note, that in order to compose the ASPxUploadControl.SaveAs method's parameter value, the HostingEnvironment.MapPath(String) method and ASPxUploadControl.FileName property are used to specify the web application's Image folder as a location where the file should be saved and define the file's name, respectively.

protected void ASPxUploadControl1_FileUploadComplete(object sender, 
DevExpress.Web.FileUploadCompleteEventArgs e) {
    if (e.IsValid) {
        e.UploadedFile.SaveAs(MapPath("Images/" + e.UploadedFile.FileName));
    }
}
See Also