add eventhandler at runtime in VB

Discussion in 'ASP .Net Web Controls' started by SteveR, Feb 7, 2005.

  1. SteveR

    SteveR Guest

    I want to add an imagebutton control into a datagrid at runtime and use the
    click event to navigate to another page. I can do this in C#
    imagebutton.click += new eventhandler... but how do I do this in VB?
    --
    Steve
     
    SteveR, Feb 7, 2005
    #1
    1. Advertising

  2. C#
    this.openFile.FileOk += New
    System.ComponentModel.CancelEventHandler(this.openFile_FileOk);

    VB.NET
    Me.openFile.FileOk += New
    System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)

    I used Kamal's site for the conversion
    http://www.kamalpatel.net/ConvertCSharp2VB.aspx

    --
    Regards,
    Alvin Bruney [MVP ASP.NET]

    [Shameless Author plug]
    The Microsoft Office Web Components Black Book with .NET
    Now Available @ http://tinyurl.com/27cok
    ----------------------------------------------------------


    "SteveR" <> wrote in message
    news:...
    >I want to add an imagebutton control into a datagrid at runtime and use the
    > click event to navigate to another page. I can do this in C#
    > imagebutton.click += new eventhandler... but how do I do this in VB?
    > --
    > Steve
     
    Alvin Bruney [MVP], Feb 8, 2005
    #2
    1. Advertising

  3. SteveR

    SteveR Guest

    Where do I have to add this? I want to add it in the ItemDataBound event of a
    datagrid but the intellisense doesn't list any of the events to add an event
    handler to. In fact I can't find anywhere where intellisense gives access to
    any of the events in the way you describe. (C# does it but this project is
    already well underway using VB so changing the language now isn't an option)
    Steve


    "Alvin Bruney [MVP]" wrote:

    > C#
    > this.openFile.FileOk += New
    > System.ComponentModel.CancelEventHandler(this.openFile_FileOk);
    >
    > VB.NET
    > Me.openFile.FileOk += New
    > System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)
    >
    > I used Kamal's site for the conversion
    > http://www.kamalpatel.net/ConvertCSharp2VB.aspx
    >
    > --
    > Regards,
    > Alvin Bruney [MVP ASP.NET]
    >
    > [Shameless Author plug]
    > The Microsoft Office Web Components Black Book with .NET
    > Now Available @ http://tinyurl.com/27cok
    > ----------------------------------------------------------
    >
    >
    > "SteveR" <> wrote in message
    > news:...
    > >I want to add an imagebutton control into a datagrid at runtime and use the
    > > click event to navigate to another page. I can do this in C#
    > > imagebutton.click += new eventhandler... but how do I do this in VB?
    > > --
    > > Steve

    >
    >
    >
     
    SteveR, Feb 8, 2005
    #3
  4. SteveR

    SteveR Guest

    I found out how to do it, you have to add:

    AddHandler tmpButton.Click, AddressOf myClick

    the definition of myClick is:

    Private Sub myClick(ByVal sender As System.Object, ByVal e As
    System.EventArgs)

    "SteveR" wrote:

    > Where do I have to add this? I want to add it in the ItemDataBound event of a
    > datagrid but the intellisense doesn't list any of the events to add an event
    > handler to. In fact I can't find anywhere where intellisense gives access to
    > any of the events in the way you describe. (C# does it but this project is
    > already well underway using VB so changing the language now isn't an option)
    > Steve
    >
    >
    > "Alvin Bruney [MVP]" wrote:
    >
    > > C#
    > > this.openFile.FileOk += New
    > > System.ComponentModel.CancelEventHandler(this.openFile_FileOk);
    > >
    > > VB.NET
    > > Me.openFile.FileOk += New
    > > System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)
    > >
    > > I used Kamal's site for the conversion
    > > http://www.kamalpatel.net/ConvertCSharp2VB.aspx
    > >
    > > --
    > > Regards,
    > > Alvin Bruney [MVP ASP.NET]
    > >
    > > [Shameless Author plug]
    > > The Microsoft Office Web Components Black Book with .NET
    > > Now Available @ http://tinyurl.com/27cok
    > > ----------------------------------------------------------
    > >
    > >
    > > "SteveR" <> wrote in message
    > > news:...
    > > >I want to add an imagebutton control into a datagrid at runtime and use the
    > > > click event to navigate to another page. I can do this in C#
    > > > imagebutton.click += new eventhandler... but how do I do this in VB?
    > > > --
    > > > Steve

    > >
    > >
    > >
     
    SteveR, Feb 15, 2005
    #4
    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. =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=

    Add an eventhandler on a button_click

    =?Utf-8?B?QWxlc3NhbmRybyBSb3NzaQ==?=, Feb 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    484
    Chris Jackson
    Feb 17, 2004
  2. Lars Netzel
    Replies:
    0
    Views:
    416
    Lars Netzel
    Jul 9, 2004
  3. Karl
    Replies:
    0
    Views:
    541
  4. Oscar
    Replies:
    6
    Views:
    21,496
    Eirik
    Jul 31, 2005
  5. Mr Not So Know It All

    Newbie question - Runtime Button and EventHandler

    Mr Not So Know It All, Mar 21, 2007, in forum: ASP .Net
    Replies:
    9
    Views:
    388
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Mar 28, 2007
Loading...

Share This Page