0

在我上传文件的用户控件中,客户端(funClientUploadComplete、funClientUploadError)和服务器端事件(uplFile1_UploadedComplete)都没有被触发。经过一番调试,发现客户端事件函数“未定义”。它们在下面的 HTML 中明确定义。为什么它们仍然“未定义”?如何成功定义/绑定它们?我怀疑这也是未调用服务器端事件函数的原因。请看下面的代码。感谢您的回复。

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<script type="text/javascript">
    function funClientUploadComplete() {
        alert('fdj-1');                            // alert box does not show
    }

    function funClientUploadError() {        
        alert('fdj-2');                            // alert box does not show    
    }

</script>

<div style="float: left;">
<asp:GridView ID="grdUploadControls" runat="server" AutoGenerateColumns="False" OnRowDataBound="grdUploadControls_RowDataBound" >
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:AsyncFileUpload ID="uplFile1" runat="server" OnUploadedComplete="uplFile1_UploadedComplete" OnClientUploadComplete="funClientUploadComplete"
                            OnClientUploadError="funClientUploadError" UploaderStyle="Modern" ClientIDMode="AutoID" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</div>

服务器端事件的代码:(未命中断点)

   protected void uplFile1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
    {
        // Typecast the source of this event to an AsynFileUpload
        AsyncFileUpload afux = (AsyncFileUpload)sender;
        .....
        .....
    }

谢谢参观!

4

0 回答 0