Catch AllFilesFinished Event

Aug 11, 2009 at 12:47 PM

Hi!

First of all, congratulations for the Code. Its very nice and usual.

My problem is: I'm new to SilverLight, so I'm getting some problems to Catch the AllFilesFinished Event.
I've looked into all files provided in the project, and also in documentation page.
Not found my answers, cause in the TestePage.aspx you create the Object in other way.

My page:

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Upload.aspx.vb" Inherits="Upload" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Upload</title>    
    
    <script type="text/javascript">

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <div>
            <asp:Silverlight ID="Xaml1" runat="server" Enabled="false"  Visible="false"
            Source="~/ClientBin/mpost.SilverlightMultiFileUpload.xap" 
            MinimumVersion="2.0.30523" 
            Windowless="true"                       
            Width="100%" 
            Height="350" 
            InitParameters="FileFilter=Imagens Jpeg (*.jpg)|*.jpg,CustomParam=1,DefaultColor=LightBlue" />
        </div>

    </form>
</body>
</html>

In fact, i cant really generate the JavaScript enough to reach the Event.
All ways i've tried not leaded me to the expected result.
Could you help me with this, writing, in this code above, how can i, for example, say a 'Hello World' when AllFilesFinished Event fires up?
Thank You!

Coordinator
Aug 11, 2009 at 12:50 PM

You can have a look at the JavascriptOnly_MultiFileUploadTestPage.html. It is included in the project and shows you exactly how to setup the JavaScript events.

Aug 11, 2009 at 2:29 PM

Absolut Fantastic...

I've faced another problem, but already solved.
For those who wants to pass a diferent path to the Imagens, follow this:

- Create a Session on YourPage.aspx.vb Page Load;
- Change the httpUploadHandler.ashx at this line: (this will enable the page to see the Sessions)
   public class HttpUploadHandler : IHttpHandler, System.Web.SessionState.IReadOnlySessionState{
- change the way the parameter is taken:
   _parameters = _httpContext.Session["Pasta"].ToString();

I've made this way, and its all right now.

Thank man, for the Code and the agility

 

Mar 10, 2011 at 10:03 AM
Edited Mar 10, 2011 at 10:04 AM

Hi, I am going crazy with a problem :D

 

AFTER uploading file/s how can refresh the page? This because I added into the default aspx page a gridview containing a files' list of Upload folder. But to bind the gridview I would need to refresh the page when uploads finish.

I tried to put this

context.Response.Redirect("Default.aspx);

into HttpUploadHandler.ashx but it doesn't run!

Help me please :)

Coordinator
Mar 10, 2011 at 10:59 AM

You need to do this at the clientside, with Javascript / AJAX.

Use the uploader's Javascript API to receive a notification when all files are finished and then refresh the page using javascript.

Mar 10, 2011 at 11:51 AM

Thank you for your quick reply.

But how can I use Javascript API? Can you write or link me an example to follow?

Coordinator
Mar 10, 2011 at 12:30 PM

There are javascript examples included within the solution in codeplex.

Mar 10, 2011 at 1:13 PM
Edited Mar 10, 2011 at 1:14 PM

THANK YOU THANK YOU my friend!!

I added this code in Default.aspx

var slCtl = null;

function AllFilesFinished() {

document.getElementById('AllFinishedDiv').style.display = 'block';

location.reload('Default.aspx');

}

function pluginLoaded(sender) {

slCtl = document.getElementById("MultiFileUploader");

slCtl.Content.Files.AllFilesFinished = AllFilesFinished;

slCtl.Content.Files.SingleFileUploadFinished = SingleFileFinished;

slCtl.Content.Files.ErrorOccurred = ShowErrorDiv;

slCtl.Content.Control.MaximumFileSizeReached = ShowMaximumFileSizeDiv;

slCtl.Content.Files.FileAdded = UpdateFileList;

slCtl.Content.Files.FileRemoved = UpdateFileList;

slCtl.Content.Files.StateChanged = UpdateFileList;

slCtl.Content.Files.TotalPercentageChanged = UpdateTotalPercentage;
}

 

Finally I added this:

<param name="onload" value="pluginLoaded" />

into silverlightControlHost and.....

IT WORKS NOW :D :D