I have an AsyncFileUpload and a Repeater that lists uploaded files. When I select a file it used to attempt to upload twice. I have a duplicate file check in .cs file so it always display "file already exists" error message. I searched for an answer and it seemed the consensus was to use IsUploading of the AsyncFileUpload and if condition was true to return and not do another __doPostBack("...").
When I set breakpoint at this JS function, I get IsUploading (or isUploading) is undefined, hence it does not return as it is supposed to still uploads twice.
I tried removing "ClientIDMode='Auto'" but it didn't help.
<ajaxToolkit:AsyncFileUpload
runat="server"
ClientIDMode="AutoID"
ID="fuDocument"
Width="380"
UploadingBackColor="#CCFFFF"
ThrobberID="myThrobber"
UploaderStyle="Modern"
OnClientUploadStarted="onClientUploadStart"
OnClientUploadComplete="onClientUploadComplete"
OnClientUploadError="onClientUploadError"
onuploadedcomplete="fuDocument_UploadedComplete" />
<span id="spnUploadInfo"></span>
function onClientUploadStart(sender, e) {
var spnUploadInfo = document.getElementById('spnUploadInfo');
spnUploadInfo.innerHTML = 'Please wait while uploading ' + e._fileName;
}
function onClientUploadError(sender, e) {
var spnUploadInfo = document.getElementById('spnUploadInfo');
spnUploadInfo.className = "Error";
spnUploadInfo.innerHTML = 'An error occurred during uploading. "' + e.get_errorMessage();
}
function onClientUploadComplete(sender, e) {debugger
var fu = $get("<%=fuDocument.ClientID%>")
if (fu.isUploading) return;
// Also tried "if (fuDocument.IsUploading)" with ClientIDMode set to Auto
var spnUploadInfo = document.getElementById('spnUploadInfo');
spnUploadInfo.innerHTML = "...";
__doPostBack('upnlAtt', '');
}