Reputation: 1124
I have asp:button and foo function. I want to programmatically add foo function for command event to that button. How can I do that? Thanks
Upvotes: 0
Views: 1078
Reputation: 4623
At an appropriate point in your page, assign the handler to the button's Command event:
btnButton.Command += new CommandEventHandler(Foo);
And then the Foo method must have the following signature:
void Foo(object sender, CommandEventArgs e)
{
// Do something here.
}
Upvotes: 3