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

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
 
A

anthony

You may need to recreate the button

Dim objButton as New Button

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

lblStatus.Text = objButton.Text
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top