|
Rank: Newbie Groups: Member
Joined: 2/17/2011 Posts: 3
|
Hi.
I was having the problem that the OnFileUploaded event wasn't firing when I found out that it only gets fired after the page gets submitted.
As a result I have a couple of questions.
1. What is the point of an AJAX uploader if the entire page needs to be submitted anyway?
2. From a technical perspective, why is this limitation? The control can clearly write the temporary files just fine, meaning that server-side code is being run, so what would prevent an event from being triggered when the file is uploaded? What technical reasons are there for the event not being triggered when the file is uploaded?
I'm not trying to argue here, I'm genuinely curious. :) It seems like a pretty weird limitation at first glance. Maybe you've got good reasons, in which case I'm all ears! Thanks!
P.S.: Unfortunately this limitation means I'll have to find something else but if there are good reasons for this behavior, then I'd really like to know about them.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You can have the uploader works the way you described by setting the uploader's AutoPostBack to true.
The upload is done by two steps. The first step is transferring the file. The step can take a while (depending on your file size). The second step is to submit the file to your code for processing. By default step 1 triggered when user clicks "Upload" button, step 2 is triggered when you post back the page (usually by clicking a submit button). If you set AutoPostBack to true, then step 2 is automatically triggered immediately after step 1 is done.
The reason to allow step 2 to be separately triggered from step 1 is to allow user to enter other contents. A typical example is an email program, you can click "upload" to start uploading an attachment, while the file is being uploaded, you can type your email. However you would not want to "send" (post back) until you are done with typing your email, even if the attachment has already finished uploading. In that case you will need a separate “Send” button that would submit both your email text and the uploaded file to your server code for processing.
Another scenario is user may upload a file and then realize that they actually accidently clicked the wrong file. In that case they can delete it and then upload another one without having to submit the page (thus submit the file for your code for processing). Try to think the uploader as a simple textbox, while user enter letters in a textbox, user would enter “files” with an uploader. They may type and delete multiple times until they are satisfied with their input, only at which point they will be comfortable to submit it to you.
Obviously not all users need these two steps to be separated. In that case you would just set AutoPostBack to true and you should be all set. So it’s not really a limitation at all.
Hope this helps. Please feel free to let us know if you have any more questions.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 2/17/2011 Posts: 3
|
Thanks for the quick response!
I still don't think this necessitates a postback. In my case, the precise reason I'm trying an AJAX uploader is to avoid a postback, so I'm afraid AutoPostBack is not a solution in my case. I can see your point for other circumstances, but I still feel that it would be tremendously helpful to have an event fired when the files arrive. Most of all, I can't see what would prevent that, seeing that it already handles the temporary files... so consider this a feature request; another event that gets fired when the files land, and another one that is fired on postback.
Anyway, I didn't come here to argue. :) Thanks for the response, very much appreciated, even if it doesn't help my situation.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You are confused about the word "postback". The #1 hard rule for ASP.NET server control is that if you want a server event based on user input, you do a post back.
AJAX does not avoid post back for you. When you do an AJAX "callback", it is executed as a post back in every sense on all levels (protocol, server and browser). The only difference is a regular post back always comes with a full page reload afterwards. An AJAX "callback" does not do this second part (or only update a portion of the page, so called "partial update").
So in your case, you will have to have a post back regardless because you want a server event. And that can be triggered by either AutoPostBack or one of your own button. You will not find a solution that doesn’t do a postback underneath. After the post back is done, whether you do a full page reload is a totally different matter and that part has nothing to do with the AJAXUploader control.
The primary goals for the AJAXUploader control are:
1. To give you live progress information while the file is being uploaded; 2. To allow you work on other part of the page while the file is being uploaded;
To simply put, instead of sitting there waiting for a whole file to be uploaded and doing nothing, you can now see something and do something else while the file is being uploaded. If that's not what you are looking for, then the uploader is probably not for you.
This is not the same sense as "avoid a postback" as you were talking about. That is taken care of by our CallbackPanel control. The CallbackPanel control can update part of the page without reloading the whole page, thus give you the impression of avoiding the postback. You can use AJAXUploader together with our CallbackPanel control to archive that impression without any problem.
Hope this clears up for you.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 2/17/2011 Posts: 3
|
Excuse my confusion over the terminology. By postback you're clearly referring to any ASP.NET HTTP call, whereas I'm specifically talking about submitting the entire page, as opposed to only the iframe (or whatever container is used) that contains the file being uploaded. Thanks for clearing up the vocabulary, but when I said postback, I meant posting the entire page as opposed to whatever it is that sends the file.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. You did not understand what we told you. When we talk about postback, we are talking about a HTTP POST on the protocol level. In ASP.NET, most post back occurs when an ASP.NET Web form posts back. You can do protocol level post back without a Web form but you will not get server event fired, so it becomes useless for your scenario. This is not about terminology or vocabulary. It’s about fundamentally how ASP.NET works.
I am glad you brought up iframe. It is quite OK to do everything inside the same post back. However by doing so you lose all the flexibility and possibility to carry other form information with your file. On the other hand, if you only want the file to be posted back right away, you can just put the control itself inside an iframe with nothing in it and do it through AutoPostBack. So there is absolutely no reason for us to choose the single post back model. And this goes the same for our competitors if their product is properly implemented.
Note even if you put it inside an iframe there are still two postbacks. There is no reason that should bother you because the overhead is negligible and it does not affect your code structure. However if you insist everything has to happen inside the same postback, then our product is not for you. We do not believe you will find one elsewhere either (the standard ASP.NET FileUpload is the only one we are aware of doing a single postback, and that’s exactly why everybody wants to replace it with a third party uploader control).
Obviously we are not here to argue with you either, however it is our goal to give you most accurate technical information as possible. We are among the first that introduced the AJAXUploader control many years ago. Thus we have a much better understanding on how this works and it is our pleasure to share. It is also our best interest to do so because other user may also have similar questions and they can benefit from the forum as well.
Thanks
|
|