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_TestImageClick
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Table1 As System.Web.UI.WebControls.Table
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.WebControls.TableRow
Dim td As New System.Web.UI.WebControls.TableCell
For i = 1 To 5
tr = New System.Web.UI.WebControls.TableRow
td = New System.Web.UI.WebControls.TableCell
Dim myLB As LinkButton
Dim obj As System.Object
myLB = New LinkButton
myLB.ID = "myLB" & i.ToString
myLB.CommandName = "Command" & i
myLB.CommandArgument = i
AddHandler myLB.Click, AddressOf DoStuff
myLB.Text = "My Link"
myLB.EnableViewState = True
td.Controls.Add(myLB)
tr.Controls.Add(td)
Table1.Controls.Add(tr)
Next
InitializeComponent()
End Sub
#End Region
Protected WithEvents myLB As System.Web.UI.WebControls.LinkButton
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
End If
End Sub
Private Sub DoStuff(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles myLB.Click
Response.Write("<script language=javascript>window.alert('It was
called')</script>")
TextBox1.Text = "Button was clicked sender.CommandName = " &
sender.CommandName & " CommandArg = " & sender.CommandArgument
End Sub