Search code examples
asp.netajaxajaxcontroltoolkit

ASP.Net Ajax AsyncFileUpload control not firing server side OnUploadCompleted event


I am writing an application that requires a user to upload files to the server machine. All user interaction with the user is done via JQuery UI modal popups. I created a test page to see that the AsyncFileUpload control works, and everything works fine on it. I added the AsyncFileUpload to the webform that I need it on, in a modal popup, but for some reason the server side event is never fired. The only difference on this page from the test page is that I send a variable through on the querystring which I, on initial load of the page, store in the viewstate (so it isn't required on future postbacks). Any ideas?

Thanks


Solution

  • When you use AsyncFileUpload you must set the right params in the "form" tag, that is placed in your Page or MasterPage:

     <form id="form1" runat="server" enctype="multipart/form-data" method="post">
    

    If you don't set the right enctype and method UploadedComplete will never fire, and you won't be able to get FileUpload.FileBytes since FileUpload.HasFile returns true only during UploadedComplete execution.

    I suppose that you didn't set the correct enctype on your modal popup.

    Besides, prevoius versions of AsyncFileUpload didn't work on Chrome. Actual version (4.1.50731.0) solved the problem.