1 Partial Class Webform2
2 Inherits System.Web.UI.Page
3
4 Dim linkButton1 As System.Web.UI.WebControls.LinkButton
5
6 Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
7
8 'loop that creates linkbuttons
9 Dim i = 0
10 For i = 0 To 5
11 linkButton1 = New LinkButton()
12 linkButton1.ID = "TesterLinkbox" + i.ToString
13 linkButton1.Text = i.ToString
14 linkButton1.CommandName = "test12"
15 linkButton1.CommandArgument = "The value i want to pass" 'i.ToString
16 linkButton1.OnClientClick = "javascript:__doPostBack('LinkButtonTest12','test1');"
17 Panel1.Controls.Add(linkButton1)
18 Next
19
20
21 End Sub
22
23 ' Did not know if i could use panel-events to handle it..???!
24
25 'Protected Sub fisk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.Init
26 ' MsgBox("Panel initialised")
27 ' Dim lb As LinkButton = CType(sender, LinkButton)
28 ' If lb.CommandName = "Fisk" Then
29 ' MsgBox(lb.CommandArgument)
30 ' Response.Write(lb.CommandArgument) 'your argument here do any thing you want
31 ' End If
32
33 'End Sub
34
35 ' Handles ordinary clicks on a normal linkbutton
36
37 Protected Sub Kongen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Kongen.Click
38 MsgBox("YES")
39 Dim lb As LinkButton = CType(sender, LinkButton)
40 If lb.CommandName = "Click" Then
41 MsgBox(lb.CommandArgument)
42 Response.Write(lb.CommandArgument)
43 End If
44
45 End Sub
46
47 Protected Sub LinkButtonTest12_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonTest12.Click
48 MsgBox("Test12")
49 Dim lb As LinkButton = CType(sender, LinkButton)
50 If lb.CommandName = "test12" Then
51 MsgBox(lb.CommandArgument)
52 'Response.Write(lb.CommandArgument) 'your argument here do any thing you want
53 End If
54 End Sub
55 End Class
56
57