0

I have a single aspx page in my web-app which shows some asp.net charts/tables/repeaters etc.

Now, when the user access the page and leave it idle for some time and click submit-button or ctrl+F5(refresh), then following exception occurs at random.

Multiple controls with the same ID 'xyz' were found. FindControl requires that controls have unique IDs.

and the thing is it has thrown exception for most of the control's on my page like labels, chart, textBox, scriptManager etc

I am unable to get the cause of these random exceptions or get what I am doing wrong in my code.

I have not dynamically generated any of the control's unique id ( from code-behind) and none of the id is duplicated on the page.

I have used Ajax control toolkit ( 7.0.x) Also at code behind I have used System.Threading.task to bind the charts/repeaters.

My ASPX file is as follows

<%@ 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%;">
                    &nbsp;
                </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>
4

1 回答 1

0

我发现的问题是 ContinueWith 任务中的回调方法。我删除了所有 continueWith 方法并在 Tasks.WaitAll() 之后调用它们

于 2013-06-18T05:15:56.173 回答