Microsoft JScript运行时错误:';clientUploadComplete';未定义

本文关键字:clientUploadComplete 未定义 JScript 运行时错误 Microsoft | 更新日期: 2023-09-27 18:20:43

我的用户控制代码抛出javascript错误。

如果我没有在主页中包含uplNewRequestCreation,那么一切都会按预期进行。所有服务器端和客户端文件上传功能都会被触发。在主页中包含更新面板的原因是为了避免整页回发。

我尝试了几种来自在线资源的解决方案,但都无济于事。

  1. 已将scriptmanagerpoxy添加到用户控制页
  2. 在pageload后面的代码中定义了javascript-这个解决方案有效,但没有触发OnUploadedComplete="uplFile1_Uploadedcomplet"
  3. 将文件上传用户控件添加为主更新面板的触发器,并将更新模式更改为条件

错误消息:初始化FileUpload.ascx.cs后,将显示以下错误消息。Microsoft JScript运行时错误:"clientUploadComplete"是未定义的

我非常感谢你的帮助!

谢谢!!!!

这是我的代码结构。

用户控制

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FileUpload.ascx.cs"
    Inherits="QTrack2.UserControls.FileUpload" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<script type="text/javascript">
    function clientUploadComplete(sender, args) {
        document.getElementById('<%= btnTrigger.ClientID %>').click();
    }
</script>
<div style="float: left; margin-left: 0px;">
    <asp:GridView ID="grdUploadControls" runat="server" AutoGenerateColumns="False" OnRowDataBound="grdUploadControls_RowDataBound"
        CssClass="uploadTable" Caption="CIQ Files Required To Be Uploaded">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Label ID="lblCIQType" CssClass="Label" runat="server" Text='<%#Eval("Key")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField Visible="false">
                <ItemTemplate>
                    <asp:Label ID="isReqlblCIQType" CssClass="Label" runat="server" Text='<%#Eval("Value")%>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ControlStyle-CssClass=" ">
                <ItemTemplate>
                    <asp:AsyncFileUpload ID="uplFile1" runat="server" OnUploadedComplete="uplFile1_UploadedComplete"
                        CompleteBackColor="#E5FFE5" ErrorBackColor="#F4ADAE" Width="300" UploaderStyle="Modern"
                        ClientIDMode="AutoID" OnClientUploadComplete="clientUploadComplete"/>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:HiddenField ID="hdnFileSavePath" runat="server" Value="" />
    <br />
</div>
<div style="float: left; margin-left: 20px; height: 40%; width: 650px; overflow: auto;
    padding-right: 20px;">
  <%--  <asp:UpdatePanel ID="upnlFileDisplayHolder" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnTrigger" />
        </Triggers>
        <ContentTemplate>--%>
            <asp:GridView ID="grdFileDisplay" runat="server" AutoGenerateColumns="false" CssClass="uploadTable"
                OnRowDataBound="grdFileDisplay_RowDataBound" Caption="CPM Files Currently Uploaded">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="lblFileType" CssClass="Label" runat="server" Text='<%#Eval("Value")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Label ID="lblFileName" CssClass="Label" runat="server" Text='<%#Eval("Key")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Button ID="btnDeleteFile" CssClass="button" runat="server" Text="Remove" OnClick="btnDeleteFile_Click" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <div>
                <asp:Button ID="btnTrigger" runat="server" Text="fdkl" Style="display: none;" OnClick="btnTrigger_Click" />
            </div>
       <%-- </ContentTemplate>
    </asp:UpdatePanel>--%>
</div>
<div style="clear: both">
</div>

调用用户控制的主页

<%@ Page Title="New Request" Language="C#" MasterPageFile="~/Site.IM.master" AutoEventWireup="true"
    CodeBehind="GenericNewRequest.aspx.cs" Inherits="QTrack2.CreatorPages.NewRequest.Scripts.Generic.GenericNewRequest" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register TagPrefix="uc1" TagName="fileUploadUserControl" Src="~/UserControls/FileUpload.ascx" %>
<%@ Register TagPrefix="uc2" TagName="ciqValidationUserControl" Src="~/UserControls/ciqValUserControl.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        // This function is called whenever the user selects expected completion date from view # 3.
        // This function checks if the selected date is less than currentDate and sets to the currentDate if true.
        function checkSelectedDate(sender, args) {
            if (sender._selectedDate < new Date()) {
                var previouslySelectedDate = sender._textbox.value;
                sender._selectedDate = new Date();
                // set the date back to the current date
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:UpdatePanel ID="uplNewRequestCreation" runat="server">
    <ContentTemplate>
    <asp:MultiView ID="mviewNewRequestCreation" runat="server" ActiveViewIndex="0">
       <View #1>
        .....
       </View #1>
       <View # 2>
           <uc1:fileUploadUserControl ID="multUplUserCntrol1" runat="server" />
          .....
       </View # 2>
       <View # 3>
       ....
       </View #3>
   </asp:MultiView>
   </ContentTemplate>
</asp:UpdatePanel>

Microsoft JScript运行时错误:';clientUploadComplete';未定义

很明显,您的Javascript函数没有在更新面板中注册,您可以这样做:

  • 在"用户控制"answers"更新面板"外部声明此函数clientUploadComplete

或者你也可以:

  • 调用文档.getElementById('<%=btnTigger.ClientID%>').click()函数没有使用javascript函数,类似这样的。。。

    OnClientUploadComplete="document.getElementById('btnTrigger_clientName').click()"

相关文章:
  • 没有找到相关文章