Welcome Guest Search | Active Topics | Sign In | Register

Number of files to upload + ErrorHandler in AJAXUploader Options
Daniele
Posted: Thursday, September 3, 2009 11:15:03 AM
Rank: Newbie
Groups: Member

Joined: 9/3/2009
Posts: 5
Hi all, I have a couple of questions about AJAXUploader.

1 - Is there a way to let users upload only one file? I need that one user could upload a file and then have only the chance to delete it and not to upload another one.

2 - In my project I'm using Master Pages and I can't add any javascript in the <head> tag. Is there a way to add a custom error handler without using a javascript function? I need to add an handler because I use the AllowedExtension property. I tried to insert javascript commands directly in ClientSideOnError, but it doesn't seem to work.


Thank you,
Daniele
eo_support
Posted: Thursday, September 3, 2009 11:39:19 AM
Rank: Administration
Groups: Administration

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

As to your question:

1. The uploader has a MaxFileCount property. You can set that property to 1 and then user will only be able to submit one file. However this property controls the number of files to be submitted, not the number of files to be uploaded. Consider the following sequence:

a. User browses and uploads file a.gif. File "a.gif" appears in the uploaded file list;
b. User deletes "a.gif". Now the file list is empty;
c. User browses and uploads file b.gif. File "b.gif" now appears in the uploaded file list;
d. User submits the page (for example, by clicking another button), file "b.gif" is submitted and your FileUploaded event is triggered;

Here user uploaded two files but only submitted one. Your code will only see "b.gif". In a way, it's like user typed letter "a" in a textbox, then typed backspace to clear it, then typed letter "b", then submit only "b" to you. Generally you should only care about number of submitted files, not number of uploaded files.

2. You will always need JavaScript to handle ClientSideOnError. The question is not JavaScript or not. The question is where you put your JavaScript.

There are a number of ways to put JavaScript in your page. You do not have to put it inside <head>. For example, you can just place it right before the AJAXUploader and it should work for you. For example:

Code: HTML/ASPX
<script type="text/javascript">
function your_error_handler(....)
{
   .....
}
</script>
<eo:AJAXUploader ClientSideOnError="your_error_handler" ... >
....
</eo:AJAXUploader>


Hope this helps.

Thanks!
Daniele
Posted: Friday, September 4, 2009 3:32:08 AM
Rank: Newbie
Groups: Member

Joined: 9/3/2009
Posts: 5
Thanks for your quick help. I put my JavaScript where you suggested and everything works! Sorry I didn't notice the MaxFileCount property, I'm a "newbie" :)

Thank you again,
Daniele
eo_support
Posted: Friday, September 4, 2009 8:13:27 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You are very welcome. Glad to hear that it works for you!


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.