ASPxUploadControl.FileUploadComplete Event
Occurs after a file has been uploaded to the server.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#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 |
---|---|
Callback |
Gets or sets a string that contains specific information (if any) to be passed from the server side to the client. |
Error |
Gets or sets the error text. |
Is |
Gets or sets a value specifying whether the uploaded file passes validation. |
Uploaded |
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).
When the UploadMode property is set to Standard
, the event is raised after a file is uploaded to the server. If the UploadMode property is set to Advanced
, the event is raised when all selected files are uploaded to the server.
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 ASPx
#Example
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 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));
}
}