Thanks for you help pointing me in the right direction. I did finally get
things working. I needed the VB commands, I needed to put the code in the
Init section of the code behind and I needed to stop doing a few stupid
things in my code.
Anyway, I have posted the page below for anyone that might be interested.
Jim
Public Class SLNet_TestImage Click
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub
Protected WithEvents TextBox1 As System.Web.UI.W ebControls.Text Box
Protected WithEvents Table1 As System.Web.UI.W ebControls.Tabl e
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
Dim i As Integer
Dim tr As New System.Web.UI.W ebControls.Tabl eRow
Dim td As New System.Web.UI.W ebControls.Tabl eCell
For i = 1 To 5
tr = New System.Web.UI.W ebControls.Tabl eRow
td = New System.Web.UI.W ebControls.Tabl eCell
Dim myLB As LinkButton
Dim obj As System.Object
myLB = New LinkButton
myLB.ID = "myLB" & i.ToString
myLB.CommandNam e = "Command" & i
myLB.CommandArg ument = i
AddHandler myLB.Click, AddressOf DoStuff
myLB.Text = "My Link"
myLB.EnableView State = True
td.Controls.Add (myLB)
tr.Controls.Add (td)
Table1.Controls .Add(tr)
Next
InitializeCompo nent()
End Sub
#End Region
Protected WithEvents myLB As System.Web.UI.W ebControls.Link Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
If Not IsPostBack Then
End If
End Sub
Private Sub DoStuff(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles myLB.Click
Response.Write( "<script language=javasc ript>window.ale rt('It was
called')</script>")
TextBox1.Text = "Button was clicked sender.CommandN ame = " &
sender.CommandN ame & " CommandArg = " & sender.CommandA rgument
End Sub
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
you need to be hooking up your onclick event to its handler. this isn't
generated for you automatically.
this.onclick += onclick handler goes here
"Jim Mitchell" <ji**********@m indspring.com> wrote in message
news:#z******** ******@TK2MSFTN GP10.phx.gbl... I have some code behind that generates 10 imagebutton controls.... I
can not seem to figure out how to trap the onclick event for each image and
determine which image was clicked.
Can someone help?
Thanks in advance.
for i = 1 to 10
img = New System.Web.UI.W ebControls.Imag eButton
img.ImageUrl = "images/buy.gif"
next