views:

90

answers:

4

I've been looking for a way to achieve this behavior and I found this sample project.

The trick in this project is that it changes the form target to an iframe created on the fly.

So far so good, I can get the byte[] on the server-side. But I need to change an image preview after the file is uploaded.

How can I get the iframe to update the main page? Would I have to save it on a file on the disk, make a javascript callback to change the image url? Is there another way to do this? What's recommended?


This control suggested by vorrtex actually causes a full page postback, am I missing something or is it the correct behavior?

A: 

Add a <script> block to the page that gets loaded in the <iframe> that interacts with the parent page and updates whatever you need to.

SLaks
AFAIK, it will allow to upload anything, except files.
Valera Kolupaev
@Valera: Huh? What are you talking about?
SLaks
@SLaks oops, I thought, that you are proposing to implement "async file upload functionality" using <script> and <iframe>, my bad.
Valera Kolupaev
+1  A: 

I recommend you to use AsyncFileUploader and UpdatePanel. You have to save file on the disk but you can use C# for changing imageUrl.

vorrtex
Actually the page keeps getting a full postback. Am I missing something?
BrunoLM
It seems that such behaviour is prohibited: http://weblogs.asp.net/leftslipper/archive/2007/03/30/why-don-t-file-uploads-work-during-async-postbacks.aspx. Maybe this is reason why Google uses flash in Gmail.
vorrtex
I see, so I will have to do the callback on javascript... Thanks for this link it was very clarifying.
BrunoLM
A: 

Visit This link for creating an asynchronous file uploader in asp.net