提问人:Snooper_A 提问时间:9/27/2023 最后编辑:Snooper_A 更新时间:9/28/2023 访问量:64
未捕获的 RangeError:ASP.NET AJAX 中的数组长度无效 - 如何解决?
Uncaught RangeError: Invalid array length in ASP.NET AJAX - How to Resolve?
问:
我在使用 AJAX 的 ASP.NET Web 应用程序时遇到了一个棘手的问题。当我按下网页上的提交按钮时,我收到一条错误消息,指出“Uncaught RangeError: Invalid array length”。奇怪的是,即使发生了这个错误,我需要的数据也正确地显示在页面上。麻烦的是,页面永远加载,并且“请稍候”消息永远不会消失。它还在浏览器的控制台中显示错误。
我的表单表
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="projectbyorganization.aspx.cs" Inherits="projectbysolution" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Register Src="ActionItemsUC.ascx" TagName="ActionItemsUC" TagPrefix="uc2" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="ajax" %>
<asp:Content ContentPlaceHolderID="DetailContentPlaceHolder" runat="server" EnableViewState="true"
ID="cntProjectByStatus">
<ajax:ScriptManagerProxy ID="stmngrProjectByStatus" runat="server">
</ajax:ScriptManagerProxy>
<asp:Timer runat="server" Enabled="false" Interval="60000" ID="tickerTimer" />
<table id="tblHighLevelPageTable" width="100%">
<tbody>
<tr>
<td>
<table style="float: left; width: 55%">
<tbody>
<tr>
<td>
<asp:Panel ID="panFilterOptionsHeader" runat="server" CssClass="panelHeader" Height="22px">
<table width="100%">
<tr>
<td>
<asp:Literal ID="litFilterOptions" runat="server" Text="Filter Options"></asp:Literal>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="panFilterOptions" runat="server" CssClass="collapsePanel">
<table style="width: 100%" cellspacing="1" cellpadding="1">
<tbody>
<tr class="oddrow">
<td>
<asp:Panel ID="panSettings" runat="server" CssClass="roundedPanel" Width="100%">
<table width="100%">
<tbody>
<tr>
<td>
<asp:Label ID="lblprojectLead" runat="server" CssClass="Label" Text="Project Lead:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlProjectLead" runat="server" CssClass="combobox" AppendDataBoundItems="true"
CausesValidation="false" EnableViewState="true" Width="350px">
<asp:ListItem Text="All" Value="0" Selected="True" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblProjectLocation" runat="server" CssClass="Label" Text="Project Location:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlProjectLocation" runat="server" CssClass="combobox" AppendDataBoundItems="true"
CausesValidation="false" EnableViewState="true">
<asp:ListItem Text="All" Value="0" Selected="true" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="Service Area:"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="(Press control to select more than one value.)"></asp:Label>
</td>
<td>
<asp:ListBox ID="lstBoxServiceArea" runat="server" SelectionMode="Multiple" DataSourceID="odsServiceArea" DataTextField="name" DataValueField="id" AppendDataBoundItems="True" OnDataBound="lstBoxServiceArea_DataBound">
<asp:ListItem Value="-1">All</asp:ListItem>
</asp:ListBox>
</td>
</tr>
<tr>
<td>
<asp:ObjectDataSource ID="odsServiceArea" runat="server" SelectMethod="SelectAllServiceArea"
TypeName="DataService.Capability" OldValuesParameterFormatString="original_{0}">
</asp:ObjectDataSource>
</td>
<td dir="ltr">
<asp:Button ID="btnSubmit" runat="server" Text=" Submit " CssClass="button" CausesValidation="false">
</asp:Button>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</tbody>
</table>
<table style="float: right; width: 40%">
<tbody>
<tr>
<td>
<asp:Panel ID="panViewOptionsHeader" runat="server" CssClass="panelHeader" Height="22px">
<table width="100%">
<tr>
<td>
<asp:Literal ID="litViewOptions" runat="server" Text="View Options"></asp:Literal>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="panViewOptions" runat="server" CssClass="collapsePanel">
<table style="width: 100%" class="tablehead" cellspacing="1" cellpadding="1">
<tbody>
<tr class="oddrow">
<td>
<asp:Panel ID="panViews" runat="server" CssClass="roundedPanel" Width="100%">
<table id="tblViews" cellpadding="4" width="95%" runat="server">
<tbody>
<tr>
<td style="vertical-align: top; text-align: left" nowrap="nowrap">
<asp:Label ID="lblHighlight" runat="server" CssClass="Label" Text="Enable Highlight:"></asp:Label>
</td>
<td>
<asp:CheckBox ID="chkHighlightEnable" runat="server" EnableViewState="true" CausesValidation="False"
AutoPostBack="true"></asp:CheckBox>
</td>
</tr>
<tr>
<td style="vertical-align: top; text-align: left; white-space: nowrap">
<asp:Label ID="lblRefresh" runat="server" CssClass="Label" Text="Auto Refresh:"></asp:Label>
</td>
<td>
<asp:CheckBox ID="chkRefresh" runat="server" EnableViewState="true" CausesValidation="False"
AutoPostBack="true" OnCheckedChanged="chkRefresh_CheckedChanged"></asp:CheckBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
</td>
<td nowrap="nowrap" style="vertical-align: top; text-align: left">
<asp:LinkButton ID="lbtnSettings" OnClick="lbtnSettings_Click" runat="server" CausesValidation="False">Reset Settings</asp:LinkButton>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</td>
</tr>
</tbody>
</table>
</asp:Panel>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<div style="width: 100%">
<a onclick="collapseAll(InnerPanels);collapseAll(MainPanels);" href="#" target="_self">
[Collapse All]</a> | <a onclick="ExpandAll(MainPanels);ExpandAll(InnerPanels);" href="#"
target="_self">[Expand All]</a>
</div>
</td>
</tr>
</tbody>
</table>
<ajax:UpdatePanel ID="upanProjectByOrganization" runat="server" UpdateMode="Conditional"
RenderMode="Block">
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
<ajax:AsyncPostBackTrigger ControlID="tickerTimer" EventName="Tick" />
<ajax:AsyncPostBackTrigger ControlID="chkRefresh" EventName="CheckedChanged" />
<ajax:AsyncPostBackTrigger ControlID="chkHighlightEnable" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<table id="tblUpdate" width="100%">
<tr>
<td>
<table width="100%">
<tbody>
<tr>
<td colspan="3">
<asp:PlaceHolder ID="plhAutogeneratedControls" runat="server"> </asp:PlaceHolder>
<asp:Literal ID="litArrays" runat="server"></asp:Literal>
<asp:Literal ID="litInnerArrays" runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td colspan="3">
<asp:Panel ID="panCapabilitiesHeader" runat="server" CssClass="collapsePanelHeader"
Height="30px" Width="100%">
<table width="100%">
<tr>
<td>
<asp:Literal ID="litOrganizations" runat="server" Text="Organizations" />
<asp:Label ID="Label4" runat="server"></asp:Label></td>
<td>
</td>
<td style="text-align: right">
<asp:Image ID="imgCapabilities" runat="server" ImageUrl="../images/expand_blue.jpg" /></td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="panOrganizationsDetails" runat="server" CssClass="collapsePanel" Height="100%"
Width="100%">
<br />
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender ID="cpanOrganizations" runat="Server" TargetControlID="panOrganizationsDetails"
ExpandControlID="panCapabilitiesHeader" CollapseControlID="panCapabilitiesHeader"
ExpandedText="(Hide Details...)" CollapsedText="(Show Details...)" ImageControlID="imgCapabilities"
ExpandedImage="~/images/collapse_blue.jpg" CollapsedImage="~/images/expand_blue.jpg"
SuppressPostBack="true" AutoExpand="false" AutoCollapse="false" BehaviorID="cpanCapabilities"
Collapsed="true">
</ajaxToolkit:CollapsiblePanelExtender>
</td>
</tr>
<tr>
<td colspan="3">
<br />
<a href="Projects/closedprojects.aspx">Closed Projects</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</ContentTemplate>
</ajax:UpdatePanel>
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
</references>
<components>
<profile id="profilecontrol" autoSave="false"/>
<select id="<%=ddlProjectLead.ClientID%>" >
<bindings>
<binding dataContext="profilecontrol" dataPath="ProjectLead" property="selectedValue" direction="InOut" />
</bindings>
</select>
<select id="<%=ddlProjectLocation.ClientID %>" >
<bindings>
<binding dataContext="profilecontrol" dataPath="ProjectLocation" property="selectedValue" direction="InOut" />
</bindings>
</select>
<checkBox id="<%=chkRefresh.ClientID %>">
<bindings>
<binding dataContext="profilecontrol" dataPath="AutoRefresh" property="checked" direction="InOut" />
</bindings>
</checkBox>
<checkBox id = "<%=chkHighlightEnable.ClientID %>">
<bindings>
<binding dataContext="profilecontrol" dataPath="Highlight" property="checked" direction="InOut" />
</bindings>
</checkBox>
</components>
</page>
</script>
</asp:Content>
在我的 aspx.cs 中
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
当我单击应用程序中的“提交”按钮时,它会触发 AJAX 调用,并且我在客户端遇到错误。我已经验证了调试时这不是服务器端错误。奇怪的是,我没有在我的应用程序中显式使用任何 JavaScript 代码。有没有一种方法可以有效地处理这些客户端错误?
<ajax:UpdatePanel ID="upanProject" runat="server" UpdateMode="Conditional"
RenderMode="Block">
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
<ajax:AsyncPostBackTrigger ControlID="tickerTimer" EventName="Tick" />
<ajax:AsyncPostBackTrigger ControlID="chkRefresh" EventName="CheckedChanged" />
<ajax:AsyncPostBackTrigger ControlID="chkHighlightEnable" EventName="CheckedChanged" />
</Triggers>
答: 暂无答案
评论
new Array(l/m)
其中 是 EITHER 或 AND 是其他数组的长度。想象一下,如果 和 会发生什么。然后,您正在尝试创建一个对于数组长度来说显然是无效值的m
2
1
l
l == 5
m == 2
new Array(2.5)