Re: OnFileUploaded event does not fire in Firefox

  •  06-30-2009, 1:13 PM

    Re: OnFileUploaded event does not fire in Firefox

    <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="SiteContent" runat="Server">
                                          <asp:Button ID="btnUpload" Text="browse" runat="server" />
                <CuteWebUI:UploadAttachments  EnableViewState="true"  OnFileUploaded="Uploader_FileUploaded" OnUploadCompleted="Uploader_UploadComplete"
                    ShowFileIcons="true" InsertButtonID="btnUpload" runat="server" ID="Attachments1">
                </CuteWebUI:UploadAttachments>
                 <asp:DataGrid OnItemCommand="OnFileRemove_Click" Font-Size="small"    runat="server" ID="articleList" ShowHeader="false"   AutoGenerateColumns="False"
                AlternatingItemStyle-BackColor="#eeeeee">
                <Columns>
                    <asp:BoundColumn DataField="Name" />
                    <asp:ButtonColumn ButtonType="PushButton" Text="Remove" />
                </Columns>
            </asp:DataGrid>
           <br />
     
    =====================
    code behind
    =====================
     
      protected void Uploader_UploadComplete(object sender, UploaderEventArgs[] args)
        {
            ShowUploadedFiles();

        }

        private void ShowUploadedFiles()
        {
            DirectoryInfo objDir = new DirectoryInfo(@"C:\Dump\test\");
            if (objDir.GetFiles().Length > 0)
            {
                articleList.DataSource = objDir.GetFiles();
                articleList.DataBind();
                articleList.Visible = true;
            }
            else
            {
                articleList.Visible = false;
            }

        }

        protected void Uploader_AttachmentCreated(object sender, AttachmentItemEventArgs args)
        {
            args.Item.MoveTo(@"C:\Dump\test\" + args.Item.FileName);
          
        }
        protected void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            try
            {

                //ONCE FILE UPLOADED TO TEMP FOLDER MOVE THEM TO USER SESSION TEMP FOLDER
                args.MoveTo(@"C:\Dump\test\" + args.FileName);
            }
            catch (Exception ex)
            {
                args.Delete();
                ShowErrorMsg(ex.Message);


            }

        }

        private void ShowErrorMsg(string sMSG)
        {
            lblMsg.Text = "Error : " + sMSG;
        }

        protected void OnFileRemove_Click(object sender, DataGridCommandEventArgs args)
        {
            try
            {
                string sFile = @"C:\Dump\test\" + args.Item.Cells[0].Text;
                if (File.Exists(sFile))
                {
                    File.Delete(sFile);
                    ShowUploadedFiles();

                }
            }
            catch (Exception ex)
            {
                ShowErrorMsg(ex.Message);

            }
     
     
     
View Complete Thread