Hi Patrick
I would do it like this:
// this is created at runtime... maybe in onLoad or by another function....
Button someButton = new Button();
someButton.Name = "OnlyCallFunctionOne";
someButton.Click += new EventHandler( DynamicButton_Click );
Button someOtherButton = new Button();
someOtherButton.Name = "OnlyCallFunctionTwo";
someOtherButton.Click += new EventHandler( DynamicButton_Click );
// then you have the Click function
private void DynamicButton_Click( object sender, EventArgs e )
{
Button btn = (Button)sender;
switch( btn.Name )
{
case "OnlyCallFunctionOne": this.FunctionOne(); break;
case "OnlyCallFunctionTwo": this. FunctionTwo(); break;
}
}
private void FunctionOne()
{
// Some code...
}
private void FunctionTwo()
{
// Some code...
}
I just noticed you said ImageButton..... it should work just the same.
Hope it helps... did it in C# since u did not specify any other
language....then again i only use c# (^_^)