2012-02-17 10 views
2

別のリピーターの2つのコントロールが同じIDを持つことができない理由について質問がありますが、更新パネルにない場合は同じIDです。リピーター内の更新パネルのIDの一致 - 「すでに定義済み...」

CS0102: The type 'ASP._8_admin_testemail_aspx' already contains a definition for 'imgThisDoesntWork' 

しかし、あなたがそうのように、更新パネルを使用していない場合、それは正常に動作します:

<asp:Repeater ID="rptFirstRepeater" runat="server"> 
     <ItemTemplate> 
      <asp:Image runat="server" ID="imgThisWorks" /> 
      <asp:UpdatePanel runat="server"> 
       <ContentTemplate> 
        <asp:Image runat="server" ID="imgThisDoesntWork" /> 
       </ContentTemplate> 
      </asp:UpdatePanel> 
     </ItemTemplate> 
    </asp:Repeater> 

    <asp:Repeater ID="rptSecondRepeater" runat="server"> 
     <ItemTemplate> 
      <asp:Image runat="server" ID="imgThisWorks" /> 
      <asp:UpdatePanel runat="server"> 
       <ContentTemplate> 
        <asp:Image runat="server" ID="imgThisDoesntWork" /> 
       </ContentTemplate> 
      </asp:UpdatePanel> 
     </ItemTemplate> 
    </asp:Repeater> 

はこのエラーを生成します...このコードを参照してください。

<asp:Repeater ID="rptFirstRepeater" runat="server"> 
     <ItemTemplate> 
      <asp:Image runat="server" ID="imgThisWorks" /> 
     </ItemTemplate> 
    </asp:Repeater> 

    <asp:Repeater ID="rptSecondRepeater" runat="server"> 
     <ItemTemplate> 
      <asp:Image runat="server" ID="imgThisWorks" /> 
     </ItemTemplate> 
    </asp:Repeater> 

私はこれが同様に更新パネルには適用されませんリピータ内のすべてのコントロールは、新しいIDSにLKE ... ctl00_cttBody_ucTestControl_rptFirstRepeater_ctl00_imgThisWorks

何かを与えていることを理解できますか? 同じIDを使用して上記のコードを動作させることはできますか? - これらの2つのリピーターが本当に1つのリピーターであるという事実は無視してください! :)

ありがとう、チャールズ。

答えて

2

Microsoftが修正しないことを決定した既知のバグのようです:おかげで、私は:)グーグル私の前の質問でそれに遭遇していなかった

http://connect.microsoft.com/VisualStudio/feedback/details/417230/updatepanel-breaks-naming-containers-compile-time-bug

At this point in time, we've decided not to fix this specific issue. Fortunately, there's a very simple workaround - avoid using the same control ID inside and outside the UpdatePanel.

+0

- 少なくとも、私は何か間違っていないことを知っている! –

+0

ようこそ。私もこの問題を認識していなかったので、ここでこの質問をするのは良いことでした:) –

関連する問題