Hi,

I have a custom control which contains (amongst other things) an imageButton.

I'm adding a handler to the "click" event of the imageButton however when the button is clicked the handler routine is not called.

Can anyone tell me where I am going wrong with this? should I be handling the click event in some other way?

here is my code:


Code:
Imports Microsoft.VisualBasic
Imports System.Web.UI.WebControls
Imports System.Web.UI

Namespace company.web.media
    Public Class movieThumbnail


        Inherits WebControl

        Private _duration As String
        Private _title As String
        Private _imageURI As String
        Private _movieID As Integer
        Private img As New ImageButton


        Public Property imageURI() As String
            Get
                Return Me._imageURI
            End Get
            Set(ByVal value As String)
                Me._imageURI = value
            End Set
        End Property
        Public Property title() As String
            Get
                Return Me._title
            End Get
            Set(ByVal value As String)
                Me._title = value
            End Set
        End Property

        Public Property duration() As String
            Get
                Return Me._duration
            End Get
            Set(ByVal value As String)
                Me._duration = value
            End Set
        End Property
        Public Property movieID() As Integer
            Get
                Return Me._movieID
            End Get
            Set(ByVal value As Integer)
                Me._movieID = value
            End Set
        End Property
        Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)

            Dim table As New Table


            'setup generic styling
            table.Font.Name = "verdana"
            table.BackColor = System.Drawing.Color.FromArgb(25, 25, 25, 25)
            table.ForeColor = Drawing.Color.LightGray
            table.Width = 107

            'add three rows
            table.Rows.Add(New TableRow)
            table.Rows.Add(New TableRow)
            table.Rows.Add(New TableRow)

            'add image to first row
            table.Rows(0).Cells.Add(New TableCell)
            table.Rows(0).Cells(0).ColumnSpan = 2
            img.ImageUrl = Me._imageURI
            img.Height = 100
            img.Width = 100
            img.Style.Add("cursor", "pointer")

            AddHandler img.Click, AddressOf imgClick

            table.Rows(0).Cells(0).Controls.Add(img)

            'add title to second row
            table.Rows(1).Cells.Add(New TableCell)
            table.Rows(1).Cells(0).Text = Me._title
            table.Rows(1).Cells(0).Font.Size = FontUnit.Point(8)

            'add duration to third row
            table.Rows(2).Cells.Add(New TableCell)
            table.Rows(2).Cells(0).Text = Me._duration
            table.Rows(2).Cells(0).Font.Size = FontUnit.Point(10)

            'render control
            table.RenderControl(writer)

        End Sub


        Private Sub imgClick(ByVal sender As Object, ByVal e As ImageClickEventArgs)
            MsgBox(Me._movieID)
        End Sub

    End Class


End Namespace


and the markup simply:

Code:
<l11:movieThumbnail runat="server" duration="14:42" title="move title" imageURI="http://www.google.co.uk/logos/newton10-tree.jpg" />