Alaattin KAYRAK
Alaattin KAYRAK

Reputation: 1124

.net button command adding programmatically

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

Answers (2)

DavidGouge
DavidGouge

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

Shekhar
Shekhar

Reputation: 11788

You need to add event handler (in your case, event handler will be foo() function) for command event.

Here you can get all the information about how to add event handler for command event.

Upvotes: 0

Related Questions