Create a form and add a panel to it. Say pnlW
In the code behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Dim tx As New TextBox
tx.Text = "Hello"
pnlW.Controls.Add(tx)
‘textbox added
Dim bx As New Button
bx.ID = "btnX"
bx.Text = "Do something"
bx.ToolTip = "Button does something"
bx.CssClass = "somecssclass"
bx.CommandArgument = "somethingunique"
‘key lines
AddHandler bx.Command, AddressOf btnX_Click
pnlW.Controls.Add(bx)
Catch ex As Exception
End Try
End Sub
Protected Sub btnX_Click(ByVal sender As System.Object, ByVal e As CommandEventArgs)
Try
Dim Arg As String = e.CommandArgument.ToString
Select Case Arg
Case Is = "somethingunique"
Response.Write(Arg)
Case Else
‘ other buttons..
End Select
Catch ex As Exception
End Try
Comments
Post a Comment