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

Discussion in 'ASP .Net' started by ronaldo, Jul 22, 2004.

  1. ronaldo

    ronaldo Guest

    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
    ronaldo, Jul 22, 2004
    #1
    1. Advertising

  2. ronaldo

    anthony Guest

    You may need to recreate the button

    Dim objButton as New Button

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

    lblStatus.Text = objButton.Text



    "ronaldo" <> wrote in message
    news:...
    > 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
    >
    >
    anthony, Jul 22, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hrvoje Vrbanc
    Replies:
    1
    Views:
    454
  2. Gopal Krish
    Replies:
    2
    Views:
    3,049
    Gopal Krish
    Oct 8, 2004
  3. msimmons
    Replies:
    0
    Views:
    454
    msimmons
    Jul 16, 2009
  4. Dr. Leff
    Replies:
    3
    Views:
    280
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    211
    David Mark
    Oct 15, 2007
Loading...

Share This Page