views:

25

answers:

1

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"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<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>
A: 

Is this a 'web application project'?

It's possible that your '.designer.cs' file is corrupted/out of date and has two copies of "Label1" within it, which could be causing your problem.

If this is the case, delete the contents of the '.designer.cs' file and the go back into your markup. Add a newline after the header line on the file, save the page, and then remove the line and save the page. This will force a re-generation of the designer, which may fix the problem.

Dan Herbert
Yes, it's a web application. I've already checked the designer file and found only one Label1 control. I will try removing the whole designer file and regenerating it to see if that fixes the problem.
ilivewithian