Hidden/Shown AsyncFileUpload Control Doesn't Fire Server-Side UploadedComplete Event

我的未来我决定 提交于 2019-12-02 04:46:10

问题


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)?


回答1:


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



来源:https://stackoverflow.com/questions/2917030/hidden-shown-asyncfileupload-control-doesnt-fire-server-side-uploadedcomplete-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!