title: VB.NET AddHandler throwing Object reference not set
body: <p>I have an ASP.NET page with code-behind in VB.NET. On the ASPX page I have a Repeater with an asp:ImageButton inside the repeater and I want to catch the clicks on the button. As far as I read I have to use FindControl and then handle the copy of the original control:</p>
  
  <pre><code>Codebehind:    
  Dim imagebutton1 As ImageButton = repeater.FindControl("btnImage1")
  AddHandler imagebutton1.Command, AddressOf ReportTransfer
  ...
  ...
  Protected Sub ReportTransfer(ByVal sender As ImageButton, ByVal args As CommandEventArgs)
  ...
  End Sub
  </code></pre>
  
  <p>ASPX page:</p>
  
  <pre><code>                &lt;td&gt;
                      &lt;asp:ImageButton runat="server" ID="btnImage1" ImageUrl="~/images/icons/icon_small.png"
                                       CommandArgument="3" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>It throws "Object reference not set to an instance of an object" on the AddHandler line and I have no idea why it is doing it (I'm a bit new with VB.NET)</p>
  
  <p>Thank you in advance</p>