0

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

3
  • @Shekhar actually i can not find anything useful Commented Jul 8, 2011 at 8:43
  • have you programmed in asp.net before? Commented Jul 8, 2011 at 8:48
  • @ub1k i am kind a newbie Commented Jul 8, 2011 at 8:50

2 Answers 2

3

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.
}
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.