moxbet wrote:I can't solve that problem, except that either I remove PostedFilesPlaceHolder or I implement my own list of files and delete button, but that will be developing ajax uploader twice.
That is probably what you should do and that's definitely not developing AJAX uploader twice. AJAX uploader is MUCH more complicated than keeping a file list. :)
Keeping a file list is relatively easy. For example, you can keep an array of strings with ViewState and then use a DataGrid to displays the array. If you need to keep multiple values per array item, you can create a single string and then concatenates them together with some delimiter such as "|", for example, "abc.gif|120". You would then rebind the DataGrid from your array whenever you change your array. This way you will have full control of everything.
If you still want to "twist" AJAXUploader futher, you can try to use the callback panel to trigger a second callback so that the uploader can update the file list for you. The basic flow is:
1. The page posts back;
2. AJAXUploader builds the file list;
3. FileUpload is fired;
4. You delete the file. However the uploader's file list is NOT updated because the list is built on step 2 and it has no knowlege to refresh the list;
5. The page is updated on the client side and you see the old list;
What you can do is to add an additional roundtrip to this flow so that:
6. The page is posted back to the server again;
7. AJAXUploader builds the file list again. This time it won't include the files deleted;
8. The page is updated on the client side you should see the new list;
You will need to add additional code in step 4 to set a variable indicating that a second round trip is needed. You can then handle the CallbackPanel's Execute event to pass this information to the client side. For example:
Code: C#
protected void CallbackPanel1_Execute(object sender, CallbackEventArgs e)
{
e.Data = m_bNeedSecondRoundTrip ? "1" : "0";
}
You will then handle the CallbackPanel's ClientSideAfterUpdate event to check this additional data and if you see it as "1", do an additional post back:
Code: HTML/ASPX
<eo:CallbackPanel ClientSideAfterUpdate="after_update" ....>
....
</eo:CallbackPanel>
Code: JavaScript
function after_update(callback, data)
{
if (data == "1")
setTimeout("eo_Callback('Callback1', 'reload_uploader')", 10);
}
This will call eo_Callback again and causes a second post back. After the second post back you should have the correct file list. However because now you have two post backs, you will see the wrong list briefly (after the first post back) and then the correct file list. If this is not fine for you, then you will have to add extra code to probably hide everything during the first post back (setting style="display:none") and then turn it back on during the second post back.
I personally do not think this is easier than the first approach, especially consider that it is not accurate at all and it introduces an extra post back. The first approach is much cleaner because you are in full control of your files. Uploader uploads the file for you and you manage the file list. It's very clean and straight forward. Anyway, the bottom line is you are asking for something that is not there, so extra code is needed one way or another. However these are the options and you can decide which one to go for.
Thanks