disabling a button when pressed

M

MattB

I want to have a "finalize sale" button that disables it's self
immediately when pressed (so they can't hit it twice). I thought putting
mybutton.enabled=false in the click event would do it, but I guess that
requires a postback. Any suggestions (or even better and example) on doing
it on the client end so it's immediate and doesn't need a postback? Thanks!

Matt
 
J

John Scalco

Matt,
The following works for me:

- drop a button on your form in the visual studio asp.net designer.
- double click on the button to generate an event handler for it.
- add some code something like below

private void Button1_Click (objecxt sneder, System.EventArgs e)
{
Button btn = (Button)sender;
btn.Enabled = false;
}

this code worked fine for me.
Just so it's clear, this is in 'code behind' - the .cs file and not the aspx
page.
If you your event code setting in there, this might have something to do
with it.

hope that helps,
sincerely,
J
 

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,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top