Search code examples
asp.netajaxfile-uploadserver-side

How to show server side errors with AjaxFileUpload asp.net?


I'm using a AjaxFileUpload control as following:

<ajaxtoolkit:AjaxFileUpload ID="upAjaxUploader" AllowedFileTypes="jpg,jpeg,jpe,jfif,png,tif,tiff,gif,bmp,dib,txt,rtf,odf,wps,doc,docx,xls,xlsx,xlsm,ods,ppt,pptx,pdf,csv,xml,xps"
                            MaximumNumberOfFiles="10" EnableViewState="true" ThrobberID="imgThrobberUpload" runat="server" Mode="Auto" />

On server I'm saving the file to a web service. I need to display errors within the control itself, e.g. at the place where it says "All Files Uploaded. Please select file(s) to upload." Also, in event of an error the file should be red in colour.

How can I achieve this? Is it possible to add some arguments or such?

PLEASE HELP! Thanks in advance, I'm stuck with this for past two days.


Solution

  • From the ajax toolkit site you need to use the OnClientUploadError method. From the site:

    OnClientUploadError - The name of a JavaScript function executed in the client-side if the file upload failed.

    I'm not too sure if you can replace the "All files uploaded..." text but you'll be able to show and hide and error div / message in the JavaScript function.