0

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', '');
}
NoBullMan
  • 2,032
  • 5
  • 40
  • 93
  • This doesn't look like C#. Why did you tag it? –  Dec 15 '16 at 15:16
  • The server side code is in C# in case someone's solution included server side modifications. But thank you for your helpful comment! – NoBullMan Dec 15 '16 at 15:52

0 Answers0