Multiple Imagebuttons Click Event

M

Michael

Hi, I hope someone can help me with this problem which has been bugging me
for some time now.
Essentially I have a WebCustomControl, that contains 5 ImageButtons. I want
this control to do something depending on which Imagebutton was clicked in
the client. (Postback).
The below code has been changed a few times around trying to figure things
out, thus I try to post just the relevant part I got.
Hope someone can shed some light.
thanks
Michael

''''''''''''Code

Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls

<DefaultProperty("Text"), ToolboxData("<{0}:rating
runat=server></{0}:rating>")> Public Class rating
Inherits System.Web.UI.WebControls.WebControl
Implements INamingContainer

Dim _initialValue As Integer
Dim _btnDisabled As Boolean
Dim _inImg As String = "pic1.gif"
Dim _outImg As String = "pic2.gif"

Protected WithEvents s1 As New ImageButton
Protected WithEvents s2 As New ImageButton
Protected WithEvents s3 As New ImageButton
Protected WithEvents s4 As New ImageButton
Protected WithEvents s5 As New ImageButton

#Region "Bindables"
.................
#End Region

Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
With output
.RenderBeginTag(HtmlTextWriterTag.Table)
.RenderBeginTag(HtmlTextWriterTag.Tr)
.RenderBeginTag(HtmlTextWriterTag.Td)
s1.RenderControl(output)
s2.RenderControl(output)
s3.RenderControl(output)
s4.RenderControl(output)
s5.RenderControl(output)
.RenderEndTag()
.RenderEndTag()
.RenderEndTag()
End With
End Sub

#Region "ButtonClicks"
Private Sub s1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles s1.Click
'This is one of the five I want to get to fire.....
Dim ex As New Exception("Test Error")
Throw ex
End Sub

Private Sub s2_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles s2.Click

End Sub

Private Sub s3_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles s3.Click

End Sub

Private Sub s4_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles s4.Click

End Sub

Private Sub s5_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles s5.Click

End Sub
#End Region

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
AddHandler s1.Click, AddressOf s1_Click
AddHandler s2.Click, AddressOf s2_Click
AddHandler s3.Click, AddressOf s3_Click
AddHandler s4.Click, AddressOf s4_Click
AddHandler s5.Click, AddressOf s5_Click

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,225
Latest member
Top Crypto Podcasts

Latest Threads

Top