Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Event Handling in VB.Net WebForms

Event Handling in VB.Net WebForms

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rohancragg
    wrote on last edited by
    #1

    I got the following code (C#) from a VSj article and dont know how I would translate it to VB.Net, can anyone help? What we are doing is adding a series of LinkButtons to a table on the page, assigning the CommandName and Text programmatically: --- System.WebControls.LinkButton btn = new LinkButton(); // assign various properties of the button... btn.Click += new new System.EventHandler(btnClick); --- the above code presumably assigns the event to a single event handler that will then be used to work out which button fired the event and act according to the CommandName But I dont know how to do similar in VB.Net. Thanks for any help... Rohan.:wtf:

    N 1 Reply Last reply
    0
    • R rohancragg

      I got the following code (C#) from a VSj article and dont know how I would translate it to VB.Net, can anyone help? What we are doing is adding a series of LinkButtons to a table on the page, assigning the CommandName and Text programmatically: --- System.WebControls.LinkButton btn = new LinkButton(); // assign various properties of the button... btn.Click += new new System.EventHandler(btnClick); --- the above code presumably assigns the event to a single event handler that will then be used to work out which button fired the event and act according to the CommandName But I dont know how to do similar in VB.Net. Thanks for any help... Rohan.:wtf:

      N Offline
      N Offline
      Nick Seng
      wrote on last edited by
      #2

      i'm not too sure with what the code is trying to do( haven't really gotten into C# yet :( ) but if it's event handling you want, this might be what you're looking for: Friend WithEvents Btn as new System.Web.UI.WebControls.LinkButton() Private Sub btnClick(_arguments_) handles btn.click _coding_ End Sub I hope that's what you're loking for!:) Notorious SMC


      The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
      Get your facts first, and then you can distort them as much as you please Mark Twain

      R 1 Reply Last reply
      0
      • N Nick Seng

        i'm not too sure with what the code is trying to do( haven't really gotten into C# yet :( ) but if it's event handling you want, this might be what you're looking for: Friend WithEvents Btn as new System.Web.UI.WebControls.LinkButton() Private Sub btnClick(_arguments_) handles btn.click _coding_ End Sub I hope that's what you're loking for!:) Notorious SMC


        The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
        Get your facts first, and then you can distort them as much as you please Mark Twain

        R Offline
        R Offline
        rohancragg
        wrote on last edited by
        #3

        The point of this is that I am programattically adding buttons at runtime so I cannot have an individual event handler for each one as I dont know how many there will be. However, the code translator at: http://www.aspalliance.com/aldotnet/examples/translate.aspx has helped me find the solution: btn.Click += new System.EventHandler(btnClick) would translate to: AddHandler btn.Click, AddressOf btnClick Thanks, Rohan :)

        N 1 Reply Last reply
        0
        • R rohancragg

          The point of this is that I am programattically adding buttons at runtime so I cannot have an individual event handler for each one as I dont know how many there will be. However, the code translator at: http://www.aspalliance.com/aldotnet/examples/translate.aspx has helped me find the solution: btn.Click += new System.EventHandler(btnClick) would translate to: AddHandler btn.Click, AddressOf btnClick Thanks, Rohan :)

          N Offline
          N Offline
          Nick Seng
          wrote on last edited by
          #4

          No, Thank You!! I learned something new today:-O Notorious SMC


          The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning Mark Twain
          Get your facts first, and then you can distort them as much as you please Mark Twain

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups