General Information
.NET Subscription
Desktop
Web
Controls and Extensions
Mainteinance Mode
Enterprise and Analytic Tools
Quality Assurance and Productivity
Frameworks and Libraries
All docs
V19.2
General Information
.NET Subscription
Desktop
Web
Controls and Extensions
Mainteinance Mode
Enterprise and Analytic Tools
Quality Assurance and Productivity
Frameworks and Libraries
19.2
19.1
18.2
18.1
17.2
ASPxClientUploadControl.FileUploadStart Event
Obsolete. Occurs on the client side before upload of the specified files starts.
Declaration
FileUploadStart: ASPxClientEvent<ASPxClientUploadControlFilesUploadStartEventHandler<ASPxClientUploadControl>>
Event Data
The FileUploadStart event handler receives an argument of the ASPxClientUploadControlFilesUploadStartEventArgs type. The following properties provide information specific to this event.
Property | Description |
---|---|
cancel | Gets or sets a value indicating whether the action which raised the event should be canceled. |
Remarks
Handle the FileUploadStart event to perform specific client actions before upload of the specified file (or files) starts. Note, when uploading multiple files, the event fires only once before the upload starts. After the files have been uploaded, the ASPxClientUploadControl.FilesUploadComplete event fires.
Examples
<script type="text/javascript">
function onFileUploadStart(s, e) {
DXUploadedFilesContainer.Clear();
}
function onFileUploadComplete(s, e) {
if(e.callbackData) {
var fileData = e.callbackData.split('|');
var fileName = fileData[0],
fileUrl = fileData[1],
fileSize = fileData[2];
DXUploadedFilesContainer.AddFile(fileName, fileUrl, fileSize);
}
}
</script>
...
<dx:ASPxUploadControl ID="UploadControl" runat="server" ClientInstanceName="UploadControl" Width="100%"
NullText="Select multiple files..." UploadMode="Advanced" ShowUploadButton="True" ShowProgressPanel="True"
OnFileUploadComplete="UploadControl_FileUploadComplete">
<AdvancedModeSettings EnableMultiSelect="True" EnableFileList="True" EnableDragAndDrop="True" />
<ValidationSettings MaxFileSize="4194304" AllowedFileExtensions=".jpg,.jpeg,.gif,.png">
</ValidationSettings>
<ClientSideEvents FilesUploadStart="onFileUploadStart" FileUploadComplete="onFileUploadComplete" />
</dx:ASPxUploadControl>
<dx:UploadedFilesContainer ID="FileContainer" runat="server" Width="100%" Height="180"
NameColumnWidth="240" SizeColumnWidth="70" HeaderText="Uploaded files" />
const string UploadDirectory = "~/UploadControl/UploadImages/";
protected void UploadControl_FileUploadComplete(object sender, FileUploadCompleteEventArgs e) {
string resultExtension = Path.GetExtension(e.UploadedFile.FileName);
string resultFileName = Path.ChangeExtension(Path.GetRandomFileName(), resultExtension);
string resultFileUrl = UploadDirectory + resultFileName;
string resultFilePath = MapPath(resultFileUrl);
//Save the uploaded file
e.UploadedFile.SaveAs(resultFilePath);
string name = e.UploadedFile.FileName;
string url = ResolveClientUrl(resultFileUrl);
long sizeInKilobytes = e.UploadedFile.ContentLength / 1024;
string sizeText = sizeInKilobytes.ToString() + " KB";
e.CallbackData = name + "|" + url + "|" + sizeText;
}
Private Const UploadDirectory As String = "~/UploadControl/UploadImages/"
Protected Sub UploadControl_FileUploadComplete(ByVal sender As Object, ByVal e As FileUploadCompleteEventArgs)
Dim resultExtension As String = Path.GetExtension(e.UploadedFile.FileName)
Dim resultFileName As String = Path.ChangeExtension(Path.GetRandomFileName(), resultExtension)
Dim resultFileUrl As String = UploadDirectory & resultFileName
Dim resultFilePath As String = MapPath(resultFileUrl)
'Save the uploaded file
e.UploadedFile.SaveAs(resultFilePath)
Dim name As String = e.UploadedFile.FileName
Dim url As String = ResolveClientUrl(resultFileUrl)
Dim sizeInKilobytes As Long = e.UploadedFile.ContentLength / 1024
Dim sizeText As String = sizeInKilobytes.ToString() & " KB"
e.CallbackData = name & "|" & url & "|" & sizeText
End Sub
See Also
Feedback