This ticket contains a workaround for BC2637. The BC2637 breaking change occurred in versions 12.2.18+ (and recent 12.2.17 hotfixes), 13.1.12+ (recent 13.1.11 hotfixes), 13.2.12+ and 14.1.8+.
ASPxUploadControl - How to get input indexes for uploaded files on the server side in MulitFile Upload scenario in Advanced mode (for BC2637, BC2645, BC2646, BC2647)
Answers approved by DevExpress Support
This workaround is relevant only in versions where the breaking change occurred and will not work in earlier versions.
You can use ASPxHiddenField to store input indexes for each file to be uploaded inside the FileUploadStart client event handler as shown below:
ASPx<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function uploaderOnFileUploadStart(s, e) {
var fileIndex = -1;
for(var inputIndex = 0; inputIndex < uploader.GetFileInputCount(); inputIndex++) {
var inputText = uploader.GetText(inputIndex);
if(inputText) {
fileIndex++;
var mapKey = "index_" + fileIndex;
hfInputFileMap.Set(mapKey, inputIndex);
}
}
}
function uploaderOnFilesUploadComplete(s, e) {
var data = e.callbackData.split('|'),
fileContainer = document.getElementById("fileContainer");
fileContainer.innerHTML = "";
for(var i = 0; dataItem = data[i]; i++)
fileContainer.innerHTML += dataItem + "<br />";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxHiddenField ID="hfInputFileMap" runat="server" ClientInstanceName="hfInputFileMap" />
<dx:ASPxUploadControl ID="UploadControl" runat="server" ClientInstanceName="uploader" Width="300"
UploadMode="Advanced" FileUploadMode="OnPageLoad" ShowUploadButton="True" ShowProgressPanel="true"
FileInputCount="3" ShowAddRemoveButtons="true"
OnFilesUploadComplete="UploadControl_FilesUploadComplete">
<AdvancedModeSettings EnableMultiSelect="false" />
<ClientSideEvents FilesUploadComplete="uploaderOnFilesUploadComplete"
FileUploadStart="uploaderOnFileUploadStart" />
<ValidationSettings AllowedFileExtensions=".gif,.jpg,.jpeg,.png" MaxFileSize="1000000">
</ValidationSettings>
</dx:ASPxUploadControl>
<br /><br />Uploaded files:
<div id="fileContainer">
</div>
</div>
</form>
</body>
</html>
After that you can get input indexes for each uploaded file inside the FilesUploadComplete server event handler as follows:
C#protected void UploadControl_FilesUploadComplete(object sender, FilesUploadCompleteEventArgs e) {
for(int fileIndex = 0; fileIndex < UploadControl.UploadedFiles.Length; fileIndex++) {
UploadedFile file = UploadControl.UploadedFiles[fileIndex];
if(string.IsNullOrEmpty(file.FileName) || !file.IsValid)
continue;
string mapKey = "index_" + fileIndex;
object inputIndexValue = hfInputFileMap[mapKey];
int inputIndex = int.Parse(inputIndexValue.ToString());
string fileString = string.Format("FileIndex = {0}, InputIndex = {1}, FileInfo = '{2} ({3}B)'", fileIndex, inputIndex, file.FileName, file.ContentLength);
e.CallbackData += fileString + "|";
}
}
Attached is a sample project which illustrates this approach.
.