This example demonstrates how to upload files on a callback and postback and handle the upload control's FilesUploadComplete
event to save the files on the server.
Create the Upload control and add two buttons to the page. To upload files on a callback or postback, enable or disable the buttons' AutoPostBack properties. When a user selects a file and clicks a button, the selected file is uploaded to the server.
To save the file to a specific location on the server, handle the upload control's FilesUploadComplete event and specify the file's name and path in the handler.
protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e) {
// ...
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);
}
}
}
}
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)