OnFileUploaded in MagicAjax panel fires for every previously uploaded file

Last post 05-28-2010, 4:06 AM by Olaf. 2 replies.
Sort Posts: Previous Next
  •  05-27-2010, 9:17 AM 61387

    OnFileUploaded in MagicAjax panel fires for every previously uploaded file

    We have purchased the control and are using it for the first time, so please excuse or possible ignorance.

    We have an ascx like this:
     
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestAjax.ascx.cs" Inherits="TestAjax" %>
    <MagicAjax:AjaxPanel runat="server" ID="MagicAjax1" AjaxCallConnection="Asynchronous">
        <asp:Button runat="server" ID="UploaderInsertButton" Text="Upload file"  />
        <asp:Panel runat="server" ID="UploaderProgressPanel">
            <asp:Label ID="UploaderProgressTextLabel" runat="server" />
        </asp:Panel>
        
        <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertButtonID='UploaderInsertButton'
            ProgressCtrlID='UploaderProgressPanel' ProgressTextID='UploaderProgressTextLabel'
            OnFileUploaded="Uploader1_FileUploaded">
        </CuteWebUI:Uploader>
    </MagicAjax:AjaxPanel>
     
    and a code behind like this:
    public partial class TestAjax : UserControl
    {
        protected void Uploader1_FileUploaded(object sender, UploaderEventArgs file)
        {
            // Safe uploaded file
            string targetFileName = String.Format("{0}/{1}", Constants.FilePathUpload, file.FileName);
            file.CopyTo(Path.Combine(Constants.FilePathUpload, targetFileName));
        }
    }
    Now, if we upload a file, OnFileUploaded fires - fine.
    If we upload a second file, OnFileUploaded fires twice, for the first as well as the second file.
    Uploading a third file makes it fire three times.
    Is there a way to keep things simple? I'd love the control to raise the event only once for each upload (and not even after POSTing the site, only in Ajax mode).

    Thanks very much in advance
    Olaf
    Filed under:
  •  05-27-2010, 8:22 PM 61404 in reply to 61387

    Re: OnFileUploaded in MagicAjax panel fires for every previously uploaded file

    Olaf,
     
    It seems that , the MagicAjax can't set the new HTML correctly after ajax posting.
     
    You can try this before we fix the issue :
     
     
        protected void Uploader1_FileUploaded(object sender, UploaderEventArgs file)
        {
            // Safe uploaded file
            string targetFileName = String.Format("{0}/{1}", Constants.FilePathUpload, file.FileName);
            file.CopyTo(Path.Combine(Constants.FilePathUpload, targetFileName));
            file.Delete();
        }
     
    Or use file.MoveTo
     
    Regards,
    Terry

     
  •  05-28-2010, 4:06 AM 61412 in reply to 61404

    Re: OnFileUploaded in MagicAjax panel fires for every previously uploaded file

    Thanks Terry for the quick reply.

    Unfortunately, this leads to another problem: after uploading, the file is blocked and can neither be moved nor deleted - the attempt throws an exception. We've had this effect before, so a hint how to solve this is highly appreciated. Any ideas?

    Regards
    Olaf
    Filed under:
View as RSS news feed in XML