views:

465

answers:

1

I recently came across the AsyncFileUpload control in the latest (3.0.40412) release of the ASP.Net Ajax Control Toolkit. There appears to be an issue when using it in a hidden control that is later revealed, such as a <div> tag with visible=false.

Example:

Page code -

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
.
.
.
<act:ToolkitScriptManager runat="server" ID="ScriptManager1" />
<asp:UpdatePanel runat="server" ID="upnlFileUpload">
    <ContentTemplate>
        <asp:Button runat="server" ID="btnShowUpload" Text="Show Upload" />
        <div runat="server" id="divUpload" visible="false">
            <act:AsyncFileUpload runat="server" id="ctlFileUpload" />
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

Server-side Code -

Protected Sub ctlFileUpload_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles ctlFileUpload.UploadedComplete

End Sub

Protected Sub btnShowUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShowUpload.Click
    divUpload.Visible = True
End Sub

I have a breakpoint on the UploadedComplete event but it never fires. However, if you take the AsyncFileUpload control out of the <div>, making it visible at initial page render, the control works as expected.

So, is this a bug within the AsynchUploadControl, or am I not grasping a fundamental concept (which happens regularly)?

+2  A: 

First, make sure your tag has the following attribuytes - enctype="multipart/form-data" method="post" Secondly, you have to have the AsyncFileUpload in an invisible DIV within a visible DIV. See these two threads on it.

http://forums.asp.net/t/1489399.aspx

http://forums.asp.net/t/1479689.aspx?PageIndex=2

DaMartyr
First, thanks for the answer. It appears to have solved the problem.Second, you're a better searcher than I am. I spent several hours yesterday looking for this, including on the asp.net site, and came up empty. Nice work.Finally, what a kludge. I hope the Ajax Control Toolkit guys give this one some attention for the next release.
Bob Mc
Adding this to the form element was enough to get it working for me: enctype="multipart/form-data" method="post". I am also not hiding the AsyncFileUpload control itself but a panel that is around the upload control.
bdwakefield