Home All Groups Group Topic Archive Search About

Events fired from dynamically created controls-VB.net

Author
1 Aug 2006 3:42 AM
ebown5
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

Author
1 Aug 2006 2:31 PM
Alessandro Zifiglio
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

<ebo***@gmail.com> ha scritto nel messaggio
Show quoteHide quote
news:1154403756.791776.213480@m79g2000cwm.googlegroups.com...
>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
>
Author
2 Aug 2006 12:49 AM
ebown5
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:
Show quoteHide quote
> 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
>
> <ebo***@gmail.com> ha scritto nel messaggio
> news:1154403756.791776.213480@m79g2000cwm.googlegroups.com...
> >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
> >
Author
2 Aug 2006 1:19 AM
ebown5
Followup:

Worked absolutely perfectly!

Exactly the way I wanted it to work.


ebo***@gmail.com wrote:
Show quoteHide quote
> 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
> >
> > <ebo***@gmail.com> ha scritto nel messaggio
> > news:1154403756.791776.213480@m79g2000cwm.googlegroups.com...
> > >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
> > >
Author
2 Aug 2006 12:49 AM
ebown5
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:
Show quoteHide quote
> 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
>
> <ebo***@gmail.com> ha scritto nel messaggio
> news:1154403756.791776.213480@m79g2000cwm.googlegroups.com...
> >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
> >
Author
2 Aug 2006 6:14 AM
Alessandro Zifiglio
You are welcome, Eric :-)

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

<ebo***@gmail.com> ha scritto nel messaggio
Show quoteHide quote
news:1154479796.981329.109550@h48g2000cwc.googlegroups.com...
> 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
>>
>> <ebo***@gmail.com> ha scritto nel messaggio
>> news:1154403756.791776.213480@m79g2000cwm.googlegroups.com...
>> >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
>> >
>