5

I'm running into an issue where I have a FileUpload control in an UpdatePanel. When I attempt to save changes and upload the file, no file is found. If I remove the UpdatePanel everything seems to work fine.

Any ideas why this might be happening? And is there a work-around?

Screenshot

Community
  • 1
  • 1
mattruma
  • 16,589
  • 32
  • 107
  • 171

1 Answers1

10

To upload a file you need to perform a full ASP.NET page postback, it does not operate over the partial postback method.

You'll need to register the button which "uploads" your file as a PostBackTrigger of the UpdatePanel's triggers.

There are lots of free (and non-free) AJAX file upload solutions, or you can easily create one, it's just a matter of putting your file upload control within an iframe and submitting the iframe page back to the server. It isn't really ajax, but it gives a visual impression of AJAX.

Aaron Powell
  • 24,927
  • 18
  • 98
  • 150
  • Took me a bit the first time and I've had to show this to people I work with quite a few times – Aaron Powell Oct 05 '08 at 11:53
  • Do you have any links to alternative AJAX file upload solutions? – mattruma Oct 05 '08 at 11:53
  • http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx is a link to making one yourself. be careful with UpdatePanels, they can be poor performers see: http://www.aaron-powell.com/blog.aspx?id=1195 and http://www.aaron-powell.com/blog.aspx?id=1209 – Aaron Powell Oct 05 '08 at 12:01
  • Also take a look at this for slow performance of an UpdatePanel http://blogs.msdn.com/tom/archive/2008/09/15/slow-performance-of-a-gridview-inside-an-updatepanel.aspx – Tom Oct 06 '08 at 17:49
  • Yeah seen your post Tom, I'm a regular reader and have that particular post flagged for keeping ;) Only thing is your method doesn't get around the response size, which can still be very large – Aaron Powell Oct 07 '08 at 02:59