Home All Groups Group Topic Archive Search About

Get argument with imageclickeventhandler.

Author
22 Feb 2009 4:20 PM
cykill
Hi.  Anyone know how to get argument from imageclickeventhandler?

ImageButton myimage = new ImageButton();
myimage.ID = "myimageid";
myimage.Click += ImageClickEventHandler(clicked);

void clicked(object sender, imageclickeventargs e){
    //get myimage.ID here?
}

Author
21 Mar 2009 11:27 PM
Luis Roquette Valdez
Hi there cykill,

This one is quite simple...

If you debug this and have a look at the "sender" object you'll easilly
figure out that it is your ImageButton...
Now all you have to do is recast it to it's own type and get the ID.

so... let's look at the code then...

/////////////////////////////////////////////////////////////////////
string myImageButtonId;

ImageButton myImageButton = (ImageButton)sender;
myImageButtonId = myImageButton.ID;
//or even simpler...
myImageButtonId = ((ImageButton)sender).ID;
/////////////////////////////////////////////////////////////////////

Hope this helped...

Show quoteHide quote
"cykill" wrote:

> Hi.  Anyone know how to get argument from imageclickeventhandler?
>
> ImageButton myimage = new ImageButton();
> myimage.ID = "myimageid";
> myimage.Click += ImageClickEventHandler(clicked);
>
> void clicked(object sender, imageclickeventargs e){
>     //get myimage.ID here?
> }
>