According to Microsoft the FileUpload control is not compatible with an AJAX UpdatePanel.
I am aware that a PostBackTrigger can be added to the submit button of the form like this:
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
The problem is that this forces the form to perform a full post-back which voids out the whole point of using the UpdatePanel in the first place. Is there a workaround to this issue that does not cause the whole page to refresh?
Can use IFrame have "target" attribute which mention to FileUpload Page OR use Jquery example at link How to make Asynchronous(AJAX) File Upload using iframe?
Add this to your button control:
-or-
Make your page Form tag look like:
The button that is triggering the upload event needs to have
UseSubmitBehavior
property set to false:I found this the other day when I ran into the same problem: http://vinayakshrestha.wordpress.com/2007/03/13/uploading-files-using-aspnet-ajax-extensions/.
For my implementation, I put the iframe in a modal popup and added a button with style="display:none" to handle the closing of the popup. In the javascript function that watches for the change in the iframe, I added document.getElementById("<%=btnCloseUpload.ClientID%>").click(); for the hidden button.
I know of a third party component that can do that. It's called "swfupload" and is free to use and open source, and uses javascript and flash to do the magic.
here is a list of the features they offer: (from their site)
They also have a demo area where you can play around with their control. That way you can make sure it is exactly what you want.
We used it in one of our projects and it has never failed us so far, so I think this is a safe bet.
oh and here is the download page: http://code.google.com/p/swfupload/
You can't upload file(s) via
AJAX
only by reloading a wholeHTML
document. You should either useiframe
s if you prefer pure HTML (this is more common, eg. used by WordPress) or something else like swfupload suggested by Sven.