Design time error - multiple controls with the same Id

Posted by ilivewithian on Stack Overflow See other posts from Stack Overflow or by ilivewithian
Published on 2009-05-22T10:28:31Z Indexed on 2010/03/24 16:03 UTC
Read the original article Hit count: 331

Filed under:

I'm using VS 2008, I have a very simple page that has a bunch 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've checked the HTML and the designer file and I can only see one control called Label1. What might be causing this?

Also, here is the aspx markup I'm having trouble with?

<%@ 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>

© Stack Overflow or respective owner

Related posts about visual-studio-2008