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();.
Related
I am using FIleUpload on an asp.net C# page and a button which upload the browsed picture. if the file being uploaded qualify some validation it is saved and instantly shown in asp.net image below the upload button. I made alot of search to find out about asp.net FileUpload control autopostback method but could not find. The problem i am having is when the user click upload button and when the page is rendered back all values in textboxes disappear and page go to the top. I want to do this task using ajax but cannot do it as FileUpload has no autopostback event. Can anybody give me some idea or any alternative way of doing this. Also any method by usisng which user will not require upload button. Thanks
You must do a full PostBack with the FileUpload Control, since it was not designed for asynchronous postback.
Look under Using the FileUpload Control in Partial-Page Updates in
MSDN FileUpload Web Server Control
But you could try using an iframe and <input type="file"/> like in this example:
Create an Ajax style File Upload
There is also an AjaxFileUpload Control from the ASP.Net Control Toolkit: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ajaxFileUpload/ajaxFileUpload.aspx
I used swfupload. Works like gmail attach. Starts uploading upon selection and can return a thumb for you to display.
I working in application development using ASP.NET in C#.
I have a Grid View which I wanted it to load at the very last of the page load.
The page should load the master page first, where all images and other functionality was loaded, then only load the GridView.
Can this achieve on c# back end code?like the page life cycle event.
Please advice, thank you in advanced.
You can't tell to load something first or last using C#, because it is about HTTP Request and Response which is basically TCP/IP. You can however use AJAX to load some of the contents first and load some other contents last handling Javascript events like onload.
EDIT
I understand loading in this context as loading the page on the client side. If you are talking about loading page on the server side, yes you can do that. You need to load contents using page lifecycle events.
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.
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.
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.