locked
AsyncFIleUpload's OnUploadComplete not firing RRS feed

  • Question

  • User1725157504 posted

    Hello!

    I've been trying to use the AsyncFileUpload on my Master Page since yesterday, but for some reason, the OnUploadComplete event just doesn't fire (I've checked it with the debugger already, and the method is not called).

    However, for some unknown reason, it only fires under certain conditions fires when the upload is done though one of the pages that use this Master Page, but it doesn't fire in any other page.

    Here's some information...

    I'm using two Master Pages: "Geral.master", "Site.master"(which contains the AsyncFileUpload and uses "Geral.master" as its master page).

    Most of the pages uses "Site.master" as the Master Page, since I need the upload function in most of the parts of my website.

    Here's the code for Site.master:

    <%@ Master Language="C#" MasterPageFile="~/Geral.master" AutoEventWireup="true" CodeFile="Site.master.cs"
        Inherits="SiteMaster" %>
    
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
    <asp:Content ID="Head" ContentPlaceHolderID="HeadContent" runat="Server">
        <asp:ContentPlaceHolder ID="HeadContent" runat="server">
        </asp:ContentPlaceHolder>
    </asp:Content>
    <asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="Server">
        <table width="98%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 80%">
                    <asp:ContentPlaceHolder ID="MainContent" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
                <td style="width: 20%" class="RightCell">
                    <asp:AsyncFileUpload ID="MusicAsyncFileUpload" runat="server" 
                        ThrobberID="UploadImage" OnUploadedComplete="MusicAsyncFileUpload_UploadedComplete"
                        PersistFile="True" />
                    <%--<p style="text-align: left">--%>
                    <asp:Image ID="UploadImage" runat="server" ImageUrl="~/image/uploading.gif" />
                    <asp:Panel ID="UploadCompletePanel" runat="server" 
                                ClientIDMode="Static">
                                <p>
                                    Upload complete! Click on the button below to give us some information about the
                                    music:</p>
                                <asp:Button ID="UploadCompleteButton" runat="server" Text="Complete" 
                                    onclick="UploadCompleteButton_Click" />
                            </asp:Panel>
                    <asp:UpdatePanel ID="FileUploadUpdatePanel" runat="server">
                        <ContentTemplate>
                        
                    <%--</p>--%>
                            
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
    </asp:Content>
    

    The page that works correctly (Musics.aspx). For some weird reason, the OnUploadComplete server-side event is only fired when the GridView is filled! If there are no rows on the GridView (and the GridView's no data message is displayed instead of the rows), then the OnUploadComplete  event is not fired!

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Musics.aspx.cs" Inherits="Musics" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
        
    <p>
    
    <%--This is the GridView that "solves" the issue when filled:--%>
        <asp:GridView ID="MusicasGridView" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" DataKeyNames="id" 
            DataSourceID="MusicasSqlDataSource" EmptyDataText="No musics found">
            <Columns>
                <asp:TemplateField HeaderText="Music" InsertVisible="False" SortExpression="id">
                    <EditItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>'></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="MusicLinkButton" runat="server" 
                            CommandArgument='<%# Eval("id") %>' oncommand="MusicLinkButton_Command" 
                            Text='<%# Eval("name") %>'></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="artist" HeaderText="Artist" 
                    SortExpression="artist" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="MusicasSqlDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Musicon %>" 
            
            
            SelectCommand="SELECT id, name, artist, filename, tags FROM Music WHERE (name LIKE '%' + @search + '%') OR (tags LIKE '%' + @search + '%') ORDER BY name">
            <SelectParameters>
                <asp:QueryStringParameter Name="search" QueryStringField="search" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
    </asp:Content>
    

     

    Could this be a bug in the AsyncFileUpload control or is it something that I'm missing?

    Thanks!!

    Wednesday, September 21, 2011 8:22 AM

All replies

  • User-1226263862 posted

    Try putting this in your master page's form tag:

    enctype="multipart/form-data"
    Wednesday, September 21, 2011 8:32 AM
  • User1725157504 posted

    Thanks for the help, but it didn't work. Do you think this could have something to do with the fact that I'm using two Master Pages?

    Wednesday, September 21, 2011 8:50 AM
  • Wednesday, September 21, 2011 11:03 PM
  • User1725157504 posted

    Hi.

     Thanks, but none of these solutions worked. Look at my form tag:

    <body>
        <form id="Form1" enctype="multipart/form-data" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div id="main" class="page">
            <div class="header">

    I also tried to make a page that has "Geral.master" directly as its master page (I've also put an AsyncFIleUpload on Geral.master just for testing purposes), but the event still doesn't fire. Is there any other issue with AsyncFileUpload?

    Thanks!

    [edit]

    I tried to put an AsyncFileUpload on the same page that "causes" the MasterPage's AsyncFileUpload do work, and it acts the same way as the Master's one.

    One more thing I found out is that there's no need of having data in the GridView in order to make the AsyncFileUploads work, but the select must occur in the SqlDataSource. When the select occurs, the AsyncFileUploads will work as expected. What is the relationship between the SqlDataSOurce/GridView and the AsyncFileUpload?

     

            <SelectParameters>
                <asp:QueryStringParameter Name="search" QueryStringField="search" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
        <asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" 
            onuploadedcomplete="AsyncFileUpload1_UploadedComplete" />
    Thursday, September 22, 2011 8:00 AM
  • User1556928295 posted

    Any solution to this yet? I have a similar problem. I created a Test websight that the AjaxFileUpload works great on. When I try to incorporate it into my project, the onuploadcomplete doesn't fire. I got it to run once and it just skips the onuploadcomplete and gives an upload error.

    Friday, June 27, 2014 4:39 PM
  • User1556928295 posted

    Are you dealing with a large file? Over 4Mb in size? Eventhough the AjaxFileUpload will take up to 1Gb, the system will time you out. I found the solution here;

    http://weblogs.asp.net/jongalloway/large-file-uploads-in-asp-net 

    changed your web.config file by adding this;

    <system.web>
       <httpRuntime executionTimeout="240" maxRequestLength="20480" />
    </system.web> 

    which in turns allows you to upload upto a 20Mb file. Hope this helps.

    Monday, June 30, 2014 5:40 PM
  • User555306248 posted

    Hi,

    Please refer to my reply of that as follow:

    http://forums.asp.net/p/1608737/4111605.aspx#4111605.

    Friday, July 4, 2014 12:40 AM