parameters with events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody,

I've got a Button on a webform and I want an onClick event.
So normally this will be something like :
/// protected void onClickEvent(Object sender, EventArgs e)

But I want to pass an extra parameter when I click on the button.
How Can I do that?

In javascript, it's easy to create your own onclick functions because you
don't need the sender en eventargs objects.

thanks

Filip
 
By LinkButton you can set two properties:

string LinkButton.CommandName
string LinkButton.CommandArgument

protected void onClickEvent(Object sender, EventArgs e)

{
LinkButton linkButton=(LinkButton)sender;
if (linkButton.CommandName=="...." && linkButton.CommandArgument=="...")
....
}
 
Hi,

Do not use OnClick, use OnCommand and use CommandArgument to set the
parameter that you need.


Cheers,
 
Hi,

I use this approach a lot with a list control, in this way you can set the
argument using databinding and you don ;t have to take care in the code
behind searching for the control that fired the event.

You use onclick when you don;t need extra info for the event, otherwise I
would use oncommand.

cheers,
 
Back
Top