从AsyncFileUpload的UploadedComplete调用方法无法按预期工作

时间:2013-05-23 18:28:05

标签: c# asp.net ajax asyncfileupload

我有一个AsyncFileUpload控件,它应该显示一个面板,并在上传成功完成后设置一些文本。当我调试它时,事件触发,我看到方法被正确调用,但表单没有更新。

这是标记:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="well well-large">
            <form class="navbar-form pull-left">
                <ajaxToolkit:AsyncFileUpload runat="server" class="search-query" ID="AsyncFileUpload" Width="400px"
                    UploadingBackColor="AppWorkspace" ThrobberID="myThrobber" CompleteBackColor="#068712" OnUploadedComplete="AsyncFileUpload_UploadedComplete" />
                <br />
            </form>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="AsyncFileUpload" EventName="UploadedComplete" />
    </Triggers>
</asp:UpdatePanel>

<asp:UpdatePanel ID="panAlertUpdatePanel" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:Panel runat="server" ID="panAlert" Visible="false">
            <div class="alert alert-success" id="divAlert" runat="server">
                <button id="Button1" runat="server" type="button" class="close" data-dismiss="alert">&times;</button>
                You shouldn't see this message!
            </div>
            <asp:Panel runat="server" ID="panMarquee" Visible="true">
                <div id="Div1" runat="server" class="progress progress-success progress-striped">
                    <div id="ProgressBar" runat="server" class="bar" style="width: 100%"></div>
                </div>
            </asp:Panel>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>

这是服务器代码:

protected void AsyncFileUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (AsyncFileUpload.HasFile)
        {

            this.SetMessage(Message.Success);
        }
        else
        {

            this.SetMessage(Message.Fail);
        }
    }

    #endregion

    #region Miscellaneous

    private enum Message { Success, Fail }
    private void SetMessage(Message msg)
    {
        if (msg == Message.Success)
        {
            this.divAlert.InnerText = "Well done! The document appears to have uploaded successfully. Please wait...";
            this.divAlert.Attributes.Add("class", "alert alert-success");
        }
        else
        {
            this.divAlert.InnerText = "Oh snap! Something broke. Please contact IT right away.";
            this.divAlert.Attributes.Add("class", "alert alert-error");
        }

        this.panAlert.Visible = true;
        this.panAlertUpdatePanel.Update();
    }

当我使用按钮作为触发器时工作正常,但是当我将其更改为AsyncFileUpload控件时却没有。

有什么想法吗?

0 个答案:

没有答案