Which button pressed?

G

Guest

I have a form containing a few asp:textbox and two asp:Button (e.g. "Undo"
and "Save"). When I get the postback from the form, how do I tell which
button was pressed?

Thanks,
Eric
 
M

Mark Fitzpatrick

Create a seperate click event for each button. Or, instead of the click
event you can also use the command event instead and pass information about
the button as a command argument.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
D

Darren Clark

Why you dont wire up the button click event of the <asp:button> SO then you
konw exactly what button was pressed
 
G

Guest

Well, three things happen. Undo_Click() Save_Click() and also the Page_Load
with IsPostBack true. What I really want to do is allow the user to edit the
fields in the textboxes and click Save when he'd like them put into the db.
As an alternative he could click Undo to revert to the stored values (i.e.
reload the page).

So how *should* I go about doing that. Sorry to be a dope but I'm just
getting started here. Thanks.

Eric
 
G

Guest

OK the light slowly dawns...

User edits text & clicks "Save" button.
Postback occurs first (do nothing),
then Save_Click() which updates db with textbox contents

User edits text & clicks "Undo" button.
Postback occurs first (do nothing),
then Undo_Click() which reloads page with original contents from db.

Thanks all.
Eric
 
J

Joan

Why do you need a round trip for the undo? Could you just use a reset
button?

: OK the light slowly dawns...
:
: User edits text & clicks "Save" button.
: Postback occurs first (do nothing),
: then Save_Click() which updates db with textbox contents
:
: User edits text & clicks "Undo" button.
: Postback occurs first (do nothing),
: then Undo_Click() which reloads page with original contents from db.
:
: Thanks all.
: Eric
:
: "Eric Nelson" wrote:
:
: > I have a form containing a few asp:textbox and two asp:Button (e.g.
"Undo"
: > and "Save"). When I get the postback from the form, how do I tell which
: > button was pressed?
: >
: > Thanks,
: > Eric
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top