Design-time error - multiple controls with the same ID

I am using VS 2008, I have a very simple page with lots of uniquely named controls. When I try to view it in design mode, I get the following error:

Error Rendering Control - Label12
An unhanded exception has occurred.
Multiple controls with the same ID 'Label1' were found. FindControl requires that controls have unique IDs

      

I checked the HTML and designer file and I can only see one control called Label1. What could be causing this?

Also, here is the aspx markup I am running into?

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CoachingAppearanceReport.aspx.vb"
    Inherits="AcademyPro.CoachingAppearanceReport" %>

<!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 runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="appearanceDetail" class="Left CriteriaContainer">
                <asp:Label ID="Label1" runat="server" Text="Appearance Type" AssociatedControlID="ddlAppearanceType" />
                <asp:DropDownList ID="ddlAppearanceType" runat="server" CssClass="AppType" OnDataBound="ddlAppearanceType_DataBound"
                    DataSourceID="odsAppearanceType" DataTextField="AppearanceType" DataValueField="AppearanceTypeCode">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="rfvAppearanceType" runat="server" 
                    ControlToValidate="ddlAppearanceType" InitialValue="" Text="*"
                    ErrorMessage="The appearance type must be selected" />
                <asp:Label ID="lblAppearanceType" runat="server" />
                <br />

                <div class="SubSettings">
                    <asp:Label ID="Label12" runat="server" Text="Subbed for" AssociatedControlID="ddlSubbedFor" />
                    <asp:DropDownList ID="ddlSubbedFor" runat="server" OnDataBound="ddlSubbedFor_DataBound"
                        DataSourceID="odsPlayersInAgeGroup" DataTextField="PlayerName" DataValueField="PlayerID">
                    </asp:DropDownList>
                    <asp:Label ID="lblSubbedFor" runat="server" />
                    <br />
                    <asp:Label ID="Label13" runat="server" Text="Mins" AssociatedControlID="txtSubMins" />                    
                    <asp:TextBox ID="txtSubMins" runat="server" MaxLength="3" CssClass="TinyWidth" />
                    <asp:Label ID="lblSubMins" runat="server" />
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>

      

0


a source to share


2 answers


Is this a "web application project"?

It is possible that your file is .designer.cs

corrupted / outdated and has two copies of "Label1" inside it, which could cause problems.



If so, delete the contents of the file " .designer.cs

" and return to your markup. Add a line line after the file header line, save the page, and then remove the line and save the page. This will re-generate the constructor, which may solve the problem.

0


a source


I just discovered the same thing - its AssociatedControlID on asp: label. When I remove, the constructor error goes away. WTH?



0


a source







All Articles