I need to be able to add multiple buttons at run time.
Although adding the buttons is easy enough I can't find how to tell it what sub routine in the back end to run when it's clicked. You can change the command name and argument, and you can also set it to run a specific sub at the client side (MyButton.ClientSideEvents.Click = "MySub"), but I can't find anything to tell it which sub to run at the back end as I don't want it to be client side.
Any help appreciated!
In addition, if you want to run different subs based on which button has been clicked you can use CommandName as identifier and call different sub routines inside the button click event handler:
void button_Click(object sender, ButtonEventArgs e)
{
WebImageButton button = (WebImageButton)sender;
if(button.CommandName == "sub1")
SubRoutine1();
else
SubRoutine2();
return;
}
--------------------------------------------------------------------------------
Sincerely,BatnasanDeveloper Support Engineer, MCADInfragisticswww.infragistics.com/support
Dalereed,
You should be able to do something along the lines of:
WebImageButton button = new WebImageButton(); button.Click += button_Click; void button_Click(object sender, ButtonEventArgs e) { // code to handle the button click }
This will cause the clicking of the button to cause a post back and run the button_Click method server side.