Hello...I have created some dynamic buttons and a click event, however, I am having problems distinguishing which button was clicked. How can I display the name of the button that was clicked?
Here is my sample code of the button created and the addhandler event.
Thank you in advance!!!!!!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim pageNumber As New Button()
Session("recordsPerPage"
= 10
Session("totalPages"
= Int(Session("totalrecords"
/ Session("recordsPerPage"
)
If (Session("totalrecords"
Mod Session("recordsPerPage"
) > 0 Then
Session("totalPages"
= Session("totalPages"
+ 1
End If
For i = 1 To Session("totalPages"
pageNumber = New Button()
pageNumber.Text = i
pageNumber.ID = "page" + i.ToString
AddHandler pageNumber.Click, AddressOf PageNumber_OnClick
pagesPlaceHolder.Controls.Add(pageNumber)
Response.Write(" "
Next
End Sub
Private Sub PageNumber_OnClick(ByVal sender As Object, _
ByVal e As System.EventArgs)
Response.Write("This is the click event"
End Sub
***I need to use the id of the item clicked to run a query, so I need to find out how to tell which button was clicked.
Here is my sample code of the button created and the addhandler event.
Thank you in advance!!!!!!
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
Dim pageNumber As New Button()
Session("recordsPerPage"
Session("totalPages"
If (Session("totalrecords"
Session("totalPages"
End If
For i = 1 To Session("totalPages"
pageNumber = New Button()
pageNumber.Text = i
pageNumber.ID = "page" + i.ToString
AddHandler pageNumber.Click, AddressOf PageNumber_OnClick
pagesPlaceHolder.Controls.Add(pageNumber)
Response.Write(" "
Next
End Sub
Private Sub PageNumber_OnClick(ByVal sender As Object, _
ByVal e As System.EventArgs)
Response.Write("This is the click event"
End Sub
***I need to use the id of the item clicked to run a query, so I need to find out how to tell which button was clicked.