Events fired from dynamically created controls-VB.net

Discussion in 'ASP .Net Web Controls' started by ebown5@gmail.com, Aug 1, 2006.

  1. Guest

    I am programming in vb.net and haven't quite grokked how to accomplish
    this task. I am a pretty proficient amateur and guessing that this is a
    relatively simple problem for an experienced object oriented
    programmer.

    I am dynamically adding images to a webpage. Based on the data there
    may be 1 to n images on any given page. I want to provide for the
    ability to click on the images and direct the user to another url. I am
    trying to use imagebuttons for this task.

    I am having trouble handling the click event for the imagebuttons
    though since they are dynamically added.

    To solve this problem I tried to create a custom class called
    myimagebutton that inherits from imagebutton. I figured that every time
    that I dynamically created an imagebutton that I would dynamically
    create an instance of the myimagebutton class instead. Myimagebutton
    would have a click event, and I would handle the event accordingly.

    Unfortunately, this problem is just beyond my current understanding of
    custom classes and events, and the tutorials that I have read are just
    not getting through to me.

    Could someone please elucidate for me in simple terms how I would
    create a click event for my custom class and how I would handle it? Is
    creating a custom imagebutton class even the way to solve this issue?

    Thanks for any light that you guys can shed on this for me.

    Eric
     
    , Aug 1, 2006
    #1
    1. Advertising

  2. hi Eric, Instead of an imagebutton, try and use a HyperLink control and set
    its imageurl property to the url of your image. Since you do not need a
    click event to occur on the serverside before you can redirect the user,
    this should work out well for you. In this way you wont need to uselessly
    bother with wiring up unnecessary events which you wont be using to start
    with, while also avoiding a roundtrip to your server before redirecting.
    Instead, in this manner, now you will be setting the NavigateUrl property to
    the url you want to the user directed to.

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net

    <> ha scritto nel messaggio
    news:...
    >I am programming in vb.net and haven't quite grokked how to accomplish
    > this task. I am a pretty proficient amateur and guessing that this is a
    > relatively simple problem for an experienced object oriented
    > programmer.
    >
    > I am dynamically adding images to a webpage. Based on the data there
    > may be 1 to n images on any given page. I want to provide for the
    > ability to click on the images and direct the user to another url. I am
    > trying to use imagebuttons for this task.
    >
    > I am having trouble handling the click event for the imagebuttons
    > though since they are dynamically added.
    >
    > To solve this problem I tried to create a custom class called
    > myimagebutton that inherits from imagebutton. I figured that every time
    > that I dynamically created an imagebutton that I would dynamically
    > create an instance of the myimagebutton class instead. Myimagebutton
    > would have a click event, and I would handle the event accordingly.
    >
    > Unfortunately, this problem is just beyond my current understanding of
    > custom classes and events, and the tutorials that I have read are just
    > not getting through to me.
    >
    > Could someone please elucidate for me in simple terms how I would
    > create a click event for my custom class and how I would handle it? Is
    > creating a custom imagebutton class even the way to solve this issue?
    >
    > Thanks for any light that you guys can shed on this for me.
    >
    > Eric
    >
     
    Alessandro Zifiglio, Aug 1, 2006
    #2
    1. Advertising

  3. Guest

    Thanks Alessandro!

    That is exactly the kind of response that helps me out. I was trying to
    solve a problem that quickly got very complex and I didn't realize that
    there were simpler solutions out there.

    I never knew that you could use hyperlinks in this way, and will put
    this idea to test very soon.

    Thanks again. Eric ;-)

    Alessandro Zifiglio wrote:
    > hi Eric, Instead of an imagebutton, try and use a HyperLink control and set
    > its imageurl property to the url of your image. Since you do not need a
    > click event to occur on the serverside before you can redirect the user,
    > this should work out well for you. In this way you wont need to uselessly
    > bother with wiring up unnecessary events which you wont be using to start
    > with, while also avoiding a roundtrip to your server before redirecting.
    > Instead, in this manner, now you will be setting the NavigateUrl property to
    > the url you want to the user directed to.
    >
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    > <> ha scritto nel messaggio
    > news:...
    > >I am programming in vb.net and haven't quite grokked how to accomplish
    > > this task. I am a pretty proficient amateur and guessing that this is a
    > > relatively simple problem for an experienced object oriented
    > > programmer.
    > >
    > > I am dynamically adding images to a webpage. Based on the data there
    > > may be 1 to n images on any given page. I want to provide for the
    > > ability to click on the images and direct the user to another url. I am
    > > trying to use imagebuttons for this task.
    > >
    > > I am having trouble handling the click event for the imagebuttons
    > > though since they are dynamically added.
    > >
    > > To solve this problem I tried to create a custom class called
    > > myimagebutton that inherits from imagebutton. I figured that every time
    > > that I dynamically created an imagebutton that I would dynamically
    > > create an instance of the myimagebutton class instead. Myimagebutton
    > > would have a click event, and I would handle the event accordingly.
    > >
    > > Unfortunately, this problem is just beyond my current understanding of
    > > custom classes and events, and the tutorials that I have read are just
    > > not getting through to me.
    > >
    > > Could someone please elucidate for me in simple terms how I would
    > > create a click event for my custom class and how I would handle it? Is
    > > creating a custom imagebutton class even the way to solve this issue?
    > >
    > > Thanks for any light that you guys can shed on this for me.
    > >
    > > Eric
    > >
     
    , Aug 2, 2006
    #3
  4. Guest

    Thanks Alessandro!

    That is exactly the kind of response that helps me out. I was trying to
    solve a problem that quickly got very complex and I didn't realize that
    there were simpler solutions out there.

    I never knew that you could use hyperlinks in this way, and will put
    this idea to test very soon.

    Thanks again. Eric ;-)

    Alessandro Zifiglio wrote:
    > hi Eric, Instead of an imagebutton, try and use a HyperLink control and set
    > its imageurl property to the url of your image. Since you do not need a
    > click event to occur on the serverside before you can redirect the user,
    > this should work out well for you. In this way you wont need to uselessly
    > bother with wiring up unnecessary events which you wont be using to start
    > with, while also avoiding a roundtrip to your server before redirecting.
    > Instead, in this manner, now you will be setting the NavigateUrl property to
    > the url you want to the user directed to.
    >
    > Regards,
    > Alessandro Zifiglio
    > http://www.AsyncUI.net
    >
    > <> ha scritto nel messaggio
    > news:...
    > >I am programming in vb.net and haven't quite grokked how to accomplish
    > > this task. I am a pretty proficient amateur and guessing that this is a
    > > relatively simple problem for an experienced object oriented
    > > programmer.
    > >
    > > I am dynamically adding images to a webpage. Based on the data there
    > > may be 1 to n images on any given page. I want to provide for the
    > > ability to click on the images and direct the user to another url. I am
    > > trying to use imagebuttons for this task.
    > >
    > > I am having trouble handling the click event for the imagebuttons
    > > though since they are dynamically added.
    > >
    > > To solve this problem I tried to create a custom class called
    > > myimagebutton that inherits from imagebutton. I figured that every time
    > > that I dynamically created an imagebutton that I would dynamically
    > > create an instance of the myimagebutton class instead. Myimagebutton
    > > would have a click event, and I would handle the event accordingly.
    > >
    > > Unfortunately, this problem is just beyond my current understanding of
    > > custom classes and events, and the tutorials that I have read are just
    > > not getting through to me.
    > >
    > > Could someone please elucidate for me in simple terms how I would
    > > create a click event for my custom class and how I would handle it? Is
    > > creating a custom imagebutton class even the way to solve this issue?
    > >
    > > Thanks for any light that you guys can shed on this for me.
    > >
    > > Eric
    > >
     
    , Aug 2, 2006
    #4
  5. Guest

    Followup:

    Worked absolutely perfectly!

    Exactly the way I wanted it to work.


    wrote:
    > Thanks Alessandro!
    >
    > That is exactly the kind of response that helps me out. I was trying to
    > solve a problem that quickly got very complex and I didn't realize that
    > there were simpler solutions out there.
    >
    > I never knew that you could use hyperlinks in this way, and will put
    > this idea to test very soon.
    >
    > Thanks again. Eric ;-)
    >
    > Alessandro Zifiglio wrote:
    > > hi Eric, Instead of an imagebutton, try and use a HyperLink control and set
    > > its imageurl property to the url of your image. Since you do not need a
    > > click event to occur on the serverside before you can redirect the user,
    > > this should work out well for you. In this way you wont need to uselessly
    > > bother with wiring up unnecessary events which you wont be using to start
    > > with, while also avoiding a roundtrip to your server before redirecting.
    > > Instead, in this manner, now you will be setting the NavigateUrl property to
    > > the url you want to the user directed to.
    > >
    > > Regards,
    > > Alessandro Zifiglio
    > > http://www.AsyncUI.net
    > >
    > > <> ha scritto nel messaggio
    > > news:...
    > > >I am programming in vb.net and haven't quite grokked how to accomplish
    > > > this task. I am a pretty proficient amateur and guessing that this is a
    > > > relatively simple problem for an experienced object oriented
    > > > programmer.
    > > >
    > > > I am dynamically adding images to a webpage. Based on the data there
    > > > may be 1 to n images on any given page. I want to provide for the
    > > > ability to click on the images and direct the user to another url. I am
    > > > trying to use imagebuttons for this task.
    > > >
    > > > I am having trouble handling the click event for the imagebuttons
    > > > though since they are dynamically added.
    > > >
    > > > To solve this problem I tried to create a custom class called
    > > > myimagebutton that inherits from imagebutton. I figured that every time
    > > > that I dynamically created an imagebutton that I would dynamically
    > > > create an instance of the myimagebutton class instead. Myimagebutton
    > > > would have a click event, and I would handle the event accordingly.
    > > >
    > > > Unfortunately, this problem is just beyond my current understanding of
    > > > custom classes and events, and the tutorials that I have read are just
    > > > not getting through to me.
    > > >
    > > > Could someone please elucidate for me in simple terms how I would
    > > > create a click event for my custom class and how I would handle it? Is
    > > > creating a custom imagebutton class even the way to solve this issue?
    > > >
    > > > Thanks for any light that you guys can shed on this for me.
    > > >
    > > > Eric
    > > >
     
    , Aug 2, 2006
    #5
  6. You are welcome, Eric :)

    Regards,
    Alessandro Zifiglio
    http://www.AsyncUI.net

    <> ha scritto nel messaggio
    news:...
    > Thanks Alessandro!
    >
    > That is exactly the kind of response that helps me out. I was trying to
    > solve a problem that quickly got very complex and I didn't realize that
    > there were simpler solutions out there.
    >
    > I never knew that you could use hyperlinks in this way, and will put
    > this idea to test very soon.
    >
    > Thanks again. Eric ;-)
    >
    > Alessandro Zifiglio wrote:
    >> hi Eric, Instead of an imagebutton, try and use a HyperLink control and
    >> set
    >> its imageurl property to the url of your image. Since you do not need a
    >> click event to occur on the serverside before you can redirect the user,
    >> this should work out well for you. In this way you wont need to uselessly
    >> bother with wiring up unnecessary events which you wont be using to start
    >> with, while also avoiding a roundtrip to your server before redirecting.
    >> Instead, in this manner, now you will be setting the NavigateUrl property
    >> to
    >> the url you want to the user directed to.
    >>
    >> Regards,
    >> Alessandro Zifiglio
    >> http://www.AsyncUI.net
    >>
    >> <> ha scritto nel messaggio
    >> news:...
    >> >I am programming in vb.net and haven't quite grokked how to accomplish
    >> > this task. I am a pretty proficient amateur and guessing that this is a
    >> > relatively simple problem for an experienced object oriented
    >> > programmer.
    >> >
    >> > I am dynamically adding images to a webpage. Based on the data there
    >> > may be 1 to n images on any given page. I want to provide for the
    >> > ability to click on the images and direct the user to another url. I am
    >> > trying to use imagebuttons for this task.
    >> >
    >> > I am having trouble handling the click event for the imagebuttons
    >> > though since they are dynamically added.
    >> >
    >> > To solve this problem I tried to create a custom class called
    >> > myimagebutton that inherits from imagebutton. I figured that every time
    >> > that I dynamically created an imagebutton that I would dynamically
    >> > create an instance of the myimagebutton class instead. Myimagebutton
    >> > would have a click event, and I would handle the event accordingly.
    >> >
    >> > Unfortunately, this problem is just beyond my current understanding of
    >> > custom classes and events, and the tutorials that I have read are just
    >> > not getting through to me.
    >> >
    >> > Could someone please elucidate for me in simple terms how I would
    >> > create a click event for my custom class and how I would handle it? Is
    >> > creating a custom imagebutton class even the way to solve this issue?
    >> >
    >> > Thanks for any light that you guys can shed on this for me.
    >> >
    >> > Eric
    >> >

    >
     
    Alessandro Zifiglio, Aug 2, 2006
    #6
    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. JezB
    Replies:
    2
    Views:
    4,864
  2. =?Utf-8?B?Qm9i?=

    Events for Dynamically created controls

    =?Utf-8?B?Qm9i?=, Sep 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    352
    =?Utf-8?B?RGFyd2lu?=
    Sep 3, 2004
  3. ami
    Replies:
    2
    Views:
    1,218
    Valerio Santinelli
    May 30, 2007
  4. msimmons
    Replies:
    0
    Views:
    500
    msimmons
    Jul 16, 2009
  5. Richard Huang
    Replies:
    1
    Views:
    136
Loading...

Share This Page