ImageButton in ASP.NET Repeater does not fire OnClick eventhandler
<p>I have an ImageButton inside a repeater control. I have attached an eventhandler to the OnClick event of the ImageButton. But when I click the ImageButton the event does not get fired. Please Let me know if I am missing something. Thanks</p>

<p>I've attached the aspx page and the codebehind file</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddTag.aspx.cs" Inherits="IV.Web.Searchv2UI.AddTag.AddTag" EnableEventValidation="false" EnableViewState="true" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head runat="server"&gt;
    &lt;title&gt;

    &lt;/title&gt;
    &lt;style type="text/css"&gt;
    .add-tag-color-required
{
    color:Red;
}

.add-tag-float-right
{
    float:right;
}

    &lt;/style&gt;
    &lt;script type="text/javascript"&gt;
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.RadWindow; //Will work in Moz in all cases, including classic dialog      
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow; //IE (and Moz as well)      
            return oWindow;
        }

        function Cancel() {
            // clean save search fields
            document.forms[0].reset();

            //get a reference to the current RadWindow
            var oWindow = GetRadWindow();
            oWindow.close();
        }

    &lt;/script&gt;
&lt;/head&gt;
&lt;body &gt;
    &lt;form id="formAddTag" runat="server"&gt;

        &lt;%-- RadScriptManager --%&gt;
        &lt;telerik:RadScriptManager ID="radScriptManager" runat="server" /&gt;
        &lt;%-- RadScriptManager --%&gt;        

         &lt;%-- Telerik Decorator --%&gt;
        &lt;telerik:RadFormDecorator id="radFormDecorator" runat="server" DecoratedControls="All" /&gt;
        &lt;%-- Telerik Decorator --%&gt;

        &lt;%-- StyleSheetManager --%&gt;
        &lt;runway:StyleSheetManager ID="runwayStyleSheetManager" runat="server" /&gt;
        &lt;%-- StyleSheetManager --%&gt;




        &lt;telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel" runat="server" /&gt;

        &lt;telerik:RadAjaxPanel ID="radAjaxPanelAddTag" runat="server" CssClass="span-12" LoadingPanelID="radAjaxLoadingPanel"&gt;
            &lt;div class="span-12 last height-2"&gt;
                &lt;div class="span-7 height-2"&gt;

                        &lt;asp:Label ID="labelAddTag" Text=" Tags" runat="server" CssClass="color-a-4" /&gt;
                        &lt;br/&gt;
                        &lt;span&gt;&amp;nbsp;Enter tags seperated by commas.&lt;/span&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;br/&gt;
                &lt;div class="span-7 last height-2"&gt;
                    &lt;telerik:RadTextBox ID="radTextBoxTags" runat="server" MaxLength="45" Width="98%" /&gt;
                    &lt;asp:RequiredFieldValidator ID="requiredFieldValidatorSearchName" runat="server" ControlToValidate="radTextBoxTags"
                                                Display="None" ErrorMessage="Tag is required."&gt;
                    &lt;/asp:RequiredFieldValidator&gt;
                &lt;/div&gt;


                &lt;div class="span-5 last height-2"&gt;

                        &lt;asp:Button id="buttonAdd" runat="server" Text="Add" CausesValidation="true" Width="45px" OnClick="buttonAdd_Click" /&gt;
                        &lt;asp:Button id="buttonCancel" runat="server" Text="Cancel" CausesValidation="false" Width="50px" OnClientClick="Cancel(); return false;" /&gt;
                 &lt;/div&gt;
                   &lt;br /&gt;     
                    &lt;div class="span-12"&gt;     
                   &lt;asp:Repeater ID="repeaterTag" runat="server"&gt;

                    &lt;ItemTemplate&gt;

                        &lt;asp:Label ID="labelTag" runat="server" Text="&lt;%#Container.DataItem %&gt;"&gt;&lt;/asp:Label&gt;
                        &lt;asp:ImageButton runat="server" ID="imageButtonRemove" ImageUrl="~/App_Themes/ChromeTheme/Images/message_close_9x9.png" ToolTip="Remove" OnClick="imageButtonRemove_Click" /&gt;

                        &lt;span&gt;&amp;nbsp;&lt;/span&gt;

                     &lt;/ItemTemplate&gt;
                   &lt;/asp:Repeater&gt;
               &lt;/div&gt;  

        &lt;/telerik:RadAjaxPanel&gt;   
        &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The code behind file is as follows.</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IV.Web.Searchv2UI.AddTag
{
 public partial class AddTag : System.Web.UI.Page
 {


  protected void Page_Load(object sender, EventArgs e)
  {
   if (!Page.IsPostBack)
   {
    List&lt;string&gt; tags = new List&lt;string&gt;();

    tags.Add("semiconductor");
    tags.Add("electronics");
    tags.Add("us");

    ViewState["Tags"] = tags;

    repeaterTag.DataSource = tags;
    repeaterTag.DataBind();



   }
  }

  protected void buttonAdd_Click(object sender, EventArgs e)
  {
   List&lt;string&gt; tags = (List&lt;string&gt;)ViewState["Tags"];
   string[] newTags = radTextBoxTags.Text.Split(',');
   if (newTags.Length &gt; 0)
   {

    foreach(string tag in newTags)
    {
     if (!tags.Contains(tag))
     {
      tags.Add(tag);
     }
    }
   }
   ViewState["Tags"] = tags;
   repeaterTag.DataSource = tags;
   repeaterTag.DataBind();

   radTextBoxTags.Text = string.Empty;
  }

  protected void imageButtonRemove_Click(object sender, EventArgs e)
  {
   List&lt;string&gt; tags = (List&lt;string&gt;)ViewState["Tags"];
   ImageButton button = (ImageButton)sender;

   Panel panel = (Panel)button.Parent;
   string tag = ((Label)(panel.Controls[1])).Text;

   tags.Remove(tag);
   ViewState["Tags"] = tags;
   repeaterTag.DataSource = tags;
   repeaterTag.DataBind();
  }
 }
}
</code></pre>
