Can any one tell me what is the difference between both of them and also why File Upload control doesn't work with Update Panel?
It's not supported by web browsers.
Why don't file uploads work during async postbacks?
Please have a look at this thread.
Related
i'm searching for a way to upload huge files with jQuery and C#/VB.net (ASP).
I want to open an uploadform, select a file and upload it. After firing the upload (submit) it must be possible to leave the page with the upload form, and switching to another page within the same domain (Fire & Forget).
Can this be realized with jQuery and C# / VB.Net. On which Keywords i have to look to find a solution to get this working or is this impossible ?
Greetings
Marcus
You can use an async upload like following and then write a code to redirect a page.
http://www.dotnetjalps.com/2011/12/async-file-upload-with-jquery-and.html
at the end of process request method write following code.
context.Response.Redirect("YourPage.aspx");
I am using simple ASP.Net File Up loader inside an AJAX Update Panel.
But I am not accessing the Path and File Name
Can you help me to solve the issue and Suggest if any other way.
Thanx and Regards
Basically, file upload does not work inside the UpdatePanel.
But what do you want to access exactly? You cannot get the path of the client file anyway.
As Remy states above, uploading files within an update is not possible.
You can make use of a PostBackTrigger within your UpdatePanel:
PostBackTrigger
The above MSDN article contains a code listing for using a PostBackTrigger with a FileUpload control.
Other approaches available to you are to use an iframe on a separate page (see: ASP.NET - Upload File With Loading Image using JavaScript and C#) or to use one of the many third party components out there which make use of javascript and flash to upload files (Find links to a couple of the more popular ones below)
Uploadify
SWFUpload
Hope this helps.
Use ASP.NET AJAX ControlToolkit AsynFileUpload
AsyncFileUpload
You need to add a Postback trigger in update panel like this:
<Triggers>
<asp:PostBackTrigger ControlID="SubmitButtonId" />
</Triggers>
Hope this will help, Please let me know for any issues
I am trying to create a form which allow async file uploading with asp.net. I realize you cannot upload a file with ajax per se so I am examining alternatives
What is the best way to do this? Create an Iframe on the page with the entire form including the file input? Can I on the parent to the frame have the submit button which forces the frame to submit and then displays some sort of spinner to indicate file is uploading? Ideally upon completion I'd like to redirect the user to another page. Is there a somewhat easy way to do this???
Have you tried using one of the jquery plugins vice doing it by hand?
http://aquantum-demo.appspot.com/file-upload
Why not use the ASP.NET AJAX Control Toolkit's AsyncFileUpload control? It's free and works pretty well.
You could use http://jquery.malsup.com/form/#file-upload
Have it post to a page that will handle a file upload on the server side in your usual way.
I like to have the page return JSON with a success/failure flag and message, then parse the response to determine if the upload succeeded.
I am using Asyncfileupload AJAX control, and want to know if there is anyway for me to automatically reload/refresh the current page after the file upload?
The whole thing loads in an iframe so not sure how to do this.
Thanks
Behrouz
According to the documentation the OnClientUploadComplete callback javascript function will be executed when the file upload completes. So you could register for this event and refresh the current page using window.location.reload();.
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?
I recommend you to use AsyncFileUploader and UpdatePanel. You have to save file on the disk but you can use C# for changing imageUrl.
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.
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.