2

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?

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

Actually the page keeps getting a full postback. Am I missing something?
It seems that such behaviour is prohibited: weblogs.asp.net/leftslipper/archive/2007/03/30/…. Maybe this is reason why Google uses flash in Gmail.
I see, so I will have to do the callback on javascript... Thanks for this link it was very clarifying.
0

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.

3 Comments

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

You can use the project mentioned below to preview the image before uploading. Working sample is also attached.

http://www.dotnetspider.com/resources/40858-Preview-Image-before-uploading-using.aspx

This uses AjaxControlToolKit's AsyncFileUploadControl and HTTPHandler to upload the image.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.