Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileUpload control inside an UpdatePanel without refreshing the whole page?

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?

like image 850
JMcCon Avatar asked Aug 30 '08 06:08

JMcCon


2 Answers

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)

  • Upload multiple files at once by ctrl/shift-selecting in dialog
  • Javascript callbacks on all events
  • Get file information before upload starts
  • Style upload elements with XHTML and css
  • Display information while files are uploading using HTML
  • No page reloads necessary
  • Works on all platforms/browsers that has Flash support.
  • Degrades gracefully to normal HTML upload form if Flash or javascript is unavailable
  • Control filesize before upload starts
  • Only display chosen filetypes in dialog
  • Queue uploads, remove/add files before starting upload

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/

like image 191
sven Avatar answered Sep 18 '22 07:09

sven


You can't upload file(s) via AJAX only by reloading a whole HTML document. You should either use iframes if you prefer pure HTML (this is more common, eg. used by WordPress) or something else like swfupload suggested by Sven.

like image 33
palotasb Avatar answered Sep 19 '22 07:09

palotasb