ASP.NET AJAX AsyncFileUpload UploadedComplete不会触发

Hag*_*nah 4 asp.net ajax

感谢您的提前注意,我是ASP.NET AJAX AsyncFileUpload的新手,所以我创建了一个aspx页面来测试它,但是看起来这个控件存在一些错误,因为服务器端UploadedComplete事件不会触发.

aspx:

<form id="form1" runat="server" method="post" enctype="multipart/form-data">
<div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
    </asp:UpdatePanel>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)

和背后的代码

public partial class Tester : System.Web.UI.Page
{
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        this.Label1.Text = "OK";
    }
}
Run Code Online (Sandbox Code Playgroud)

有谁请让我知道为什么它不起作用?非常感谢

Ema*_*eco 7

When you use AsyncFileUpload you must set the right params in the "form" tag, that is placed in your Page or MasterPage:

 <form id="form1" runat="server" enctype="multipart/form-data" method="post">
Run Code Online (Sandbox Code Playgroud)

If you don't set the right enctype enctype="multipart/form-data" method UploadedComplete will never fire, and you won't be able to get FileUpload.FileBytes since FileUpload.HasFile returns true only during UploadedComplete execution.

Besides, prevoius versions of AsyncFileUpload didn't work on Chrome. Version from 4.1.50731.0 solved the problem.