How to handle dynamically created buttons in ASP.NET using VB.net

  • Thread starter Thread starter ronaldo
  • Start date Start date
R

ronaldo

As title, I used the following code to create a button and assign the event
handle dynamically.

private sub showOrderList()
...
Dim btnRemove As New Button
btnRemove.ID = "r" & strMyProductId
btnRemove.Text = "Remove"
btnRemove.Attributes("style")
="font-family:arial;font-size:8pt"
btnRemove.CausesValidation = False
AddHandler btnRemove.Click, AddressOf removeItem
.......
end sub

However, I found that the function removeItem never been called.
Can you tell me how can I fixed?
I found that most of the solution found in web are in C# and not in VB.net.
Would you tell me whether there are only C# solution?

thank you
 
You may need to recreate the button

Dim objButton as New Button

objButton = Page.FindControl("r" & strMyProductId)

lblStatus.Text = objButton.Text
 
Back
Top