隐藏/显示的 AsyncFileUpload 控件不会触发服务器端 UploadedComplete 事件

发布于 2024-09-02 17:54:01 字数 1385 浏览 5 评论 0原文

我最近在最新版本 (3.0.40412) 的 ASP.Net Ajax Control Toolkit 中发现了 AsyncFileUpload 控件。在稍后显示的隐藏控件中使用它时似乎存在问题,例如带有 visible=false

标记。

示例:

页面代码 -

<%@ 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>

服务器端代码 -

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

我在 UploadedComplete 事件上有一个断点,但它从未触发。但是,如果将 AsyncFileUpload 控件从

中取出,使其在初始页面呈现时可见,则该控件将按预期工作。

那么,这是 AsynchUploadControl 中的一个错误,还是我没有掌握一个基本概念(这种情况经常发生)?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清欢 2024-09-09 17:54:01

首先,确保您的标签具有以下属性 - enctype="multipart/form-data" method="post" 其次,您必须将 AsyncFileUpload 放在可见 DIV 中的不可见 DIV 中。看看这两个线程就可以了。

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文