FileUploaded event is not fired!

Last post 12-09-2008, 6:53 AM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  12-07-2008, 12:16 PM 46642

    FileUploaded event is not fired!

    Hi, I have added a handler in  Page_Init event like this:

    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    'MyBase.OnInit(e)

    AddHandler Uploader1.FileUploaded, AddressOf Uploader_FileUploaded

     

    End Sub

    I debugged but Uploader_FileUploaded function does not executed, any idea why this happens?
     
    Here is my entire code:
     

    <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1"

    InsertText="Browse Files (Max 1M)" >

    <VALIDATEOPTION MaxSizeKB="1024" />

    </CuteWebUI:UploadAttachments>

    <br />

    <br />

    <asp:Button runat="server" ID="SubmitButton" OnClick="SubmitButton_Click" OnClientClick="return submitbutton_click()" Text="Submit" />

    <br />

    <br />

    <div>

    <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>

    </div>

    <br />

    <br />

    <asp:Button ID="ButtonPostBack" Text="This is a PostBack button" runat="server" />

     

    Protected Sub InsertMsg(ByVal msg As String)

    ListBoxEvents.Items.Insert(0, msg)

    ListBoxEvents.SelectedIndex = 0

    End Sub

     

     

    Protected Sub ButtonPostBack_Click(ByVal sender As Object, ByVal e As EventArgs)

    InsertMsg("You clicked a PostBack Button.")

    End Sub

    Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As EventArgs)

    InsertMsg("You clicked the Submit Button.")

    InsertMsg("You have uploaded " & uploadcount & "/" & Uploader1.Items.Count & " files.")

    End Sub

     

    Protected Sub Uploader_FileUploaded(ByVal sender As Object, ByVal args As UploaderEventArgs)

    uploadcount += 1

    Dim uploader As CuteWebUI.Uploader = DirectCast(sender, CuteWebUI.Uploader)

    InsertMsg("File uploaded! " & args.FileName & ", " & args.FileSize & " bytes.")

    'Copys the uploaded file to a new location.

    args.CopyTo(Session("CurrentPath").ToString)

    End Sub

     

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender

     

    SubmitButton.Attributes("itemcount") = Uploader1.Items.Count.ToString()

    lblUploadPath.Text = Session("CurrentPath").ToString

    updpnlUpload.Update()

    End Sub

    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    'MyBase.OnInit(e)

    AddHandler Uploader1.FileUploaded, AddressOf Uploader_FileUploaded

    AddHandler ButtonPostBack.Click, AddressOf ButtonPostBack_Click

    End Sub

  •  12-08-2008, 3:35 AM 46650 in reply to 46642

    Re: FileUploaded event is not fired!

    Hi cassini,
     
    You have missed the following script
     
     
     
         <script type="text/javascript">
     
     function submitbutton_click()
     {
      var submitbutton=document.getElementById('<%=SubmitButton.ClientID %>');
      var uploadobj=document.getElementById('<%=Uploader1.ClientID %>');
      if(!window.filesuploaded)
      {
       if(uploadobj.getqueuecount()>0)
       {
        uploadobj.startupload();
       }
       else
       {
        var uploadedcount=parseInt(submitbutton.getAttribute("itemcount"))||0;
        if(uploadedcount>0)
        {
         return true;
        }
        alert("Please browse files for upload");
       }
       return false;
      }
      window.filesuploaded=false;
      return true;
     }
     function CuteWebUI_AjaxUploader_OnPostback()
     {
      window.filesuploaded=true;
      var submitbutton=document.getElementById('<%=SubmitButton.ClientID %>');
      submitbutton.click();
      return false;
     }
        </script>
     
     
     
    Regards,
     
    Ken
  •  12-08-2008, 4:17 AM 46651 in reply to 46650

    Re: FileUploaded event is not fired!

    No I did not, I just missed to put it here in this forum.
  •  12-09-2008, 6:53 AM 46675 in reply to 46651

    Re: FileUploaded event is not fired!

    Hi cassini,
     
     
    Our demo works fine for you?
     
    It does not work when you do some change?
     
    If so, please send you page to me, I will do moer test.
     
     
     
    Regards,
     
    Ken
     
View as RSS news feed in XML