Button Click event

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
 
M

Mark Rae

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...?
 
C

Curious Trigger

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
 
N

Newish

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
 
M

Mark Rae

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top