我的网络应用程序中有一个aspx页面,其中显示了一些asp.net图表/表格/中继器等。
现在,当用户访问该页面并将其闲置一段时间并单击时 提交按钮或ctrl + F5(刷新),然后随机发生异常。
找到具有相同ID“xyz”的多个控件。的FindControl 要求控件具有唯一ID。
然而事实是,我的页面上的大多数控件都抛出了异常 像标签,图表,textBox,scriptManager等
我无法得到这些随机异常的原因,或者在我的代码中弄错了。
我没有动态生成任何控件的唯一ID(来自代码隐藏),并且页面上没有任何id重复。
我使用过Ajax控件工具包(7.0.x) 同样在代码背后我使用System.Threading.task来绑定图表/转发器。
我的ASPX文件如下
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dashboard.aspx.cs" Inherits="Report.Dashboard" %>
<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>title1</title>
<link href="css/Report.css" rel="stylesheet" type="text/css" />
<script src="Scripts/Report.js" type="text/javascript"></script>
</head>
<body>
<div id="divHeader">
<table class="dataTable">
<tr style="text-align: right; width: 100%;">
<td style="min-width: 75%;">
</td>
<td class="headerUserName">
<asp:Label ID="lblWelcome" runat="server" Style="" Text="Welcome"></asp:Label>
<asp:Label ID="lblUserName" class="userName" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="width: 100%;">
<td class="columnWithImage" colspan="2">
<img alt="LOGO" src="images/logo.png" width="259" height="38" />
</td>
</tr>
</table>
</div>
<div id="divMain" class="marginT10">
<div id="divLeftSegment">
</div>
<div id="divImgLoading" class="divModalBackground">
<img id="imgLoading" class="loaderImage" src="images/ajax-loader.gif" alt="" />
</div>
<div id="divFormSegment">
<form id="form1" runat="server">
<div id="divMainSegment">
<asp:ScriptManager ID="smScriptManager" runat="server" EnableViewState="false">
</asp:ScriptManager>
<div id="divQueryHeader">
<table>
<tr>
<td>
<asp:Label ID="lblStartDate" runat="server" Text="Start Date"></asp:Label>
<asp:TextBox ID="txtStartDate" runat="server" ContentEditable="false" Width="125px"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="cldrStartDate" runat="server" TargetControlID="txtStartDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:Label ID="lblEndDate" CssClass="margingL15" runat="server" Text="End Date"></asp:Label>
<asp:TextBox ID="txtEndDate" runat="server" ContentEditable="false" Width="125px"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="cldrEndDate" runat="server" TargetControlID="txtEndDate">
</ajaxToolkit:CalendarExtender>
</td>
<td>
<asp:Label ID="lblMinTotal" CssClass="margingL15" runat="server" Text="Min. Total Bill"></asp:Label>
<asp:TextBox ID="txtMinTotal" runat="server" Width="125px" onkeypress="return IsOneDecimalPoint(event);"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtenderMinTotal" runat="server"
FilterType="Custom" ValidChars="01234567890." TargetControlID="txtMinTotal">
</ajaxToolkit:FilteredTextBoxExtender>
</td>
<td>
<asp:Label ID="lblMaxTotal" CssClass="margingL15" runat="server" Text="Max. Total Bill"></asp:Label>
<asp:TextBox ID="txtMaxTotal" runat="server" Width="125px" onkeypress="return IsOneDecimalPoint(event);"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtenderMaxTotal" runat="server"
FilterType="Custom" ValidChars="01234567890." TargetControlID="txtMaxTotal">
</ajaxToolkit:FilteredTextBoxExtender>
</td>
<td>
<asp:Button ID="btnUpdate" runat="server" Text="View" CssClass="margingL15"
Width="100px" OnClick="btnUpdate_Click" OnClientClick="showLoadingImg();" />
</td>
</tr>
</table>
</div>
<div style="height: Auto;">
<div id="div3">
<div id="div4" runat="server">
<table style="width: 98%;">
<tr>
<td>
<asp:Chart ID="chart1" runat="server" Width="500px">
<Series>
<asp:Series ChartType="Pie" Name="series1" IsValueShownAsLabel="true"
XValueMember="Category" YValueMembers="Count">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="chartArea1">
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Name="legend1" Docking="Bottom">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Name="title1" Text="Category">
</asp:Title>
</Titles>
</asp:Chart>
</td>
<td>
<asp:Chart ID="chart2" runat="server" Width="500px">
<Series>
<asp:Series Name="series1" XValueMember="Age" YValueMembers="Count"
ToolTip="#VALY">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="chartArea1">
</asp:ChartArea>
</ChartAreas>
<Titles>
<asp:Title Name="title1" Text="Age">
</asp:Title>
</Titles>
</asp:Chart>
</td>
</tr>
</table>
</div>
<div id="div5" class="marginT15" runat="server">
<asp:Repeater ID="rpt1" runat="server">
<HeaderTemplate>
<table class="tbl1" rules="all" border="1">
<tr>
<td class="tableColHeader">
Name
</td>
<td class="tableColHeader">
Address
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="cellStyle">
<%# Eval("Name")%>
</td>
<td class="tableCellStyle">
<%# Eval("Address")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
<div id="div6" runat="server">
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
我发现的问题是ContinueWith中的回调方法。 我删除了所有的continueWith方法 并在Tasks.WaitAll()
之后调用它们