Welcome Guest Search | Active Topics | Sign In | Register

ClientSideOnProgress and getPercentage Options
OneMHz
Posted: Wednesday, September 19, 2007 12:08:15 PM
Rank: Newbie
Groups: Member

Joined: 9/17/2007
Posts: 9
I've set up a small website with an AJAXUploader and I load that into an iframe on another site. What I'm trying to do is give myself the option to have a callback so that the parent page can be notified when the upload is complete so that I can update my display of uploaded files. I'm trying to use the ClientSideOnProgress and getPercentage to determine when the file is done uploading.

The problem is that I'm looking for getPercentage() == 100, but I get 3 to 5 ClientSideOnProgress events where it is 100. Sometimes I get one where it says the value of getPercentage() is "Infinity".

Can I reliably check for "Infinity" or is there something else I can trap?
eo_support
Posted: Wednesday, September 19, 2007 12:39:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Don't rely on that, getPercentage is a rounded value, so if the total is 1000 bytes and 999 bytes have been done, you will get round(99.9) = 100.

You can either rely on AutoPostBack to inform you that the upload has been done; or rely on the second and the third parameter of ClientSideOnProgress handler, which gives you the total number of bytes and total number of transfered bytes respectively. If you see both number greater than zero and have the same value, that means the upload is done.

Thanks
OneMHz
Posted: Wednesday, September 19, 2007 12:49:46 PM
Rank: Newbie
Groups: Member

Joined: 9/17/2007
Posts: 9
How would I use the AutoPostback? I've actually got AutoPostback set to true for my uploader (user only uploads one file at a time). Does that affect the technique?

Thanks!
eo_support
Posted: Wednesday, September 19, 2007 12:53:05 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Well, if you use AutoPostBack then you don't need to use ClientSideOnProgress to catch whether the upload has completed. When AutoPostBack is set to true, the uploader will trigger server side event FileUploaded immediately when the upload is done. Inside there you can perform any operation just like you handle a Button_Click event.

Thanks
OneMHz
Posted: Friday, September 21, 2007 10:15:55 AM
Rank: Newbie
Groups: Member

Joined: 9/17/2007
Posts: 9
Your first solution to use the total vs received bytes solved the issue of the event firing off twice, but it caused another problem. When total = received, the file name turns to null. I'm trying to save file meta data (file name, size, etc) to a database. The database code is being run in my main web application on one server and the file upload is being done on another server (throug the iframe). I need to pass data from my iframe back to my main page. I don't know of an easy way to pass the data from a server side event handler to the parent page, so I was trying to do it through javascript (have a callback style javascript function in the parent aspx and check in the iframe's aspx if it exists, and if it does, call it). The method worked, but I can't seem to get all the data I need.
eo_support
Posted: Friday, September 21, 2007 10:20:59 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

That's fairly easy. Just use a global variable to remember the last file name you see before you see total = received.

Thanks
OneMHz
Posted: Friday, September 21, 2007 10:25:50 AM
Rank: Newbie
Groups: Member

Joined: 9/17/2007
Posts: 9
I thought of doing that.

PS - The developer support here is some of the best I've seen. Great job guys!
eo_support
Posted: Friday, September 21, 2007 10:40:47 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
OneMHz wrote:
I thought of doing that.

PS - The developer support here is some of the best I've seen. Great job guys!


Good to hear that. Please spread the word. :)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.