Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader - missing server side "FileUploaded" event Options
mcSquare
Posted: Monday, June 16, 2008 3:41:43 AM
Rank: Member
Groups: Member

Joined: 6/10/2008
Posts: 12
Dear Support,
I have to validate the files before uploading them and implemented your solution from your previous post
http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1008

Now I dont get the FileUploaded event any more. Here is the code:

Quote:

<eo:AJAXUploader ID="AJAXUploader1" runat="server" Width="250px"
ClientSideOnProgress="uploader_progress_handler" Rows="3"
DeleteButtonText="Ausgewählte Dateien löschen" AllowedExtension=""
ProgressBarSkin="Windows_Vista" ClientSideOnLoad=""
ClientSideOnError="uploader_error_handler" onfileuploaded="On_FileUploaded"
TempFileLocation="" AutoPostBack="True">
<LayoutTemplate>
<table border="0" cellPadding="2" cellSpacing="0" style="width: 498px">
<tr>
<td width="30px">Software</td>
<td rowspan="3" colspan="2">
<asp:PlaceHolder runat="server" id="InputPlaceHolder">Input Box Place Holder
</asp:PlaceHolder>
</td>
</tr>
<tr><td width="30px">Dokumentation</td></tr>
<tr><td width="30px">Skript</td></tr>
<tr>
<td>&nbsp;</td>
<td colspan="2" align="right">
<asp:Button runat="server" ID="UploadButton" Text="Übertragen" Width="82px"
CssClass="styleDisplayNone" />
<input id="btnUpload" type="button" value="Einlagern" onclick="on_start_upload();" />
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="style9">
<eo:ProgressBar runat="server" id="ProgressBar" ControlSkinID="Windows_Vista" />
</td>
<td rowspan="2" align="right" valign="top">
<asp:Button runat="server" ID="CancelButton" Text="Abbruch" Width="81px" />
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="style9">
<asp:PlaceHolder runat="server" id="ProgressTextPlaceHolder">Progress Text Place Holder
</asp:PlaceHolder>
</td>
</tr>
</table>
</LayoutTemplate>
</eo:AJAXUploader>


(AutoPostBack is set to true, TempFileLocation is assigned within the code-behind file.)

The client side script that starts the upload is here: As you can see, I have to do another postback before the upload, because every single input box has a certain meaning and I found no other way for the server side to keep the information, what file was entered into what input box. (Using 3 different uploaders was impractible because only one at a time can upload files)

Quote:

function on_start_upload()
{
// verify files .... [omitted]

// notify original file names related to their meanings
var oFileSoftware = document.getElementById("AJAXUploader1_i_0");
var oFileDokumentation = document.getElementById("AJAXUploader1_i_1");
var oFileSkript = document.getElementById("AJAXUploader1_i_2");

var strSoftware = oFileSoftware.value;
var strDokumentation = oFileDokumentation.value;
var strSkript = oFileSkript.value;

// send message
var strMessage = "UPLOAD:SW=" + strSoftware+";DOKU="+strDokumentation+";SCRIPT="+strSkript;
eo_Callback("cbpMessage", strMessage);

// start upload
var btn = document.getElementById("AJAXUploader1_UploadButton");
btn.onclick();
}



The element "cbpMessage" is a callback panel, that parses the message strMessage, stores the assignments into Session and renders short feedback. Normally the "FileUploaded" event handler should iterate through the "PostedFiles" collection, find the temporary files and move/rename them according to their asociated meaning stored in the Session object.

Can you tell me, why "FileUploaded" is not called (no post back is done after upload)? Is there a smarter way to upload 3 files and to find out, in what input box they were entered? What is the method "upload()" at the client uploader object for? It seems that it simply does nothing..

If there is no other solution, I could post back my own "upload_finished" event via the cbpMessage panel. But in this case I dont get the temporary names of the uploaded files from AJAXUploader. Is there a way to get the GUID that the uploader uses to create the temp file names?

Thanks in advance!
Karsten
eo_support
Posted: Monday, June 16, 2008 8:48:16 AM
Rank: Administration
Groups: Administration

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

The problem might be eo_Callback. I do not think you can do another postback (btn.onclick()) immediately after eo_Callback. eo_Callback will start a postback and any further post back will be ignored until that one is done.

You can try the following step:

1. Remove the "start upload" part from your on_start_upload;
2. Handle the CallbackPanel's ClientSideAfterUpdate event, inside that event call window.setTimeout("start_uploader", 10);
3. Add a new function start_uploader, place the code you removed from "start_upload" here;

This way by the time you call btn.click(), the AJAX call is already completely done.

upload() at the client uploader object is the same as btn.click(). It's the recommended method since you no longer need to hook up to the upload button.

Let us know how it goes!

Thanks
mcSquare
Posted: Friday, June 27, 2008 2:16:28 AM
Rank: Member
Groups: Member

Joined: 6/10/2008
Posts: 12
Thanks a lot, but it didn't work. I changed the architecture and user experience a bit to avoid that scenario. Meanwhile I found out that every panel the upload control is nested in must have "EnableViewState" enabled ... maybe that was the cause.
eo_support
Posted: Friday, June 27, 2008 8:50:45 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,096
mcSquare wrote:
Meanwhile I found out that every panel the upload control is nested in must have "EnableViewState" enabled ... maybe that was the cause.


I believe that is true. Uploader uses ViewState to store status information which is necessary to trigger the event.


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.