title: ASP.NET Button OnClick within Repeater and LoginView
body: <p>I'm developing a ASP.NET website with a C# backend.  I'm having a problem with how to set an onclick event for buttons that are nested inside of both a loginview and a repeater.  The code works fine for displaying all of the other data (anonymous view displays only an error message) but right now the buttons just redirect to the same page and remove the repeater and all contents, whereas they're supposed to run a specific delete function.  The repeater, as it is right now, uses an alternatingitem template.  If I remove the buttons from the nested controls, they work.  I've tried this with buttons, linkbuttons, and imagebuttons.  I'd rather use the latter, if possible.  Is it possible to assign an Onclick to these buttons if they're nested like this?  If not, what approach should I use?</p>
  
  <pre><code>&lt;asp:LoginView ID="LoginLinksView" runat="server" EnableViewState="false"&gt;
  &lt;AnonymousTemplate&gt;
      &lt;asp:Label ID="errorlabel" runat="server"&gt;&lt;/asp:Label&gt;
  &lt;/AnonymousTemplate&gt;
  &lt;LoggedInTemplate&gt;
      &lt;asp:Repeater id="Repeater" runat="server" &gt;
      &lt;HeaderTemplate&gt;
       &lt;table cellspacing="0" cellpadding="0"&gt;
       &lt;thead&gt;&lt;/thead&gt;
      &lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
      &lt;tr class="Repeaterrow"&gt;
      &lt;!--Additional code here--&gt;
  
      &lt;asp:ImageButton ID="delbutton" runat="server" ImageUrl=
           "~/Images/delete.png" Onclick="DeleteOnClick"/&gt;        
      &lt;/tr&gt; 
      &lt;/ItemTemplate&gt;   
  
      &lt;AlternatingItemTemplate&gt;
      &lt;tr class="Repeaterrow"&gt;
      &lt;!--Additional code here--&gt;
  
      &lt;asp:ImageButton ID="delbutton" runat="server" ImageUrl=
           "~/Images/delete.png" Onclick="DeleteOnClick"/&gt;             
      &lt;/tr&gt;
      &lt;/AlternatingItemTemplate&gt;
  
      &lt;FooterTemplate&gt;  
      &lt;/table&gt;
      &lt;/FooterTemplate&gt;
  
      &lt;/asp:Repeater&gt;
  &lt;/LoggedInTemplate&gt;
  &lt;/asp:LoginView&gt;
  </code></pre>