Button Click event

  • Thread starter Thread starter Newish
  • Start date Start date
N

Newish

Hi

If there are, say, three buttons on an asp 2 page. User clicks on one
of them. The page is posted back. What is the easiest way to
determine which button was clicked.

thanks

Newish
 
If there are, say, three buttons on an asp 2 page. User clicks on one
of them. The page is posted back. What is the easiest way to
determine which button was clicked.

Do they all call the same function when posted back, then...?
 
If all three buttons have their attribute AutoPostBack set to true you will
be able to implent three different event handler for the click-event.
Therefore there is no need to distinguish between the buttons, because each
event handler is only called if its button was clicked.

Curious Trigger
 
Hi Mark

Thanks for writing back.

Yes they all will call the same function. In fact if i can throw
another complexity in the scenario. The buttons will be dynamically
created based on the database records that will be displayed on the
page so the number of buttons will vary and can be a lot more than
three.

Kind regards

Newish
 
Yes they all will call the same function. In fact if i can throw
another complexity in the scenario. The buttons will be dynamically
created based on the database records that will be displayed on the
page so the number of buttons will vary and can be a lot more than
three.

In which case, you need the Command method, not the Click method, and pass a
unique identifier in the CommandArgument parameter...
 
Back
Top