ASP.Net Code to make Input button disappear immediately

C

Colin Graham

I have been working on a form to update a database when i enter
details and click a button. My issue is that some of the users click
the button twice. I want to remove the button when i click it and show
a label saying "Processing"

How can i do this using the attributes.add code ???

thanks in advance

C
 
A

Anders Norås [MCAD]

I have been working on a form to update a database when i enter
details and click a button. My issue is that some of the users click
the button twice. I want to remove the button when i click it and show
a label saying "Processing"
The easiest is to disable the button and change the button text. You can do
this with JavaScript, but be aware that users can disable JavaScript in
their browsers.

Just add this to your Page_Load handler:
MyButton.Attributes.Add("onclick","this.disabled=true;this.value=\"Processing...\";");

To show hide the button and show a label instead, just alter the JavaScript
code.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
E

Eliyahu Goldin

Anders Norås said:
, but be aware that users can disable JavaScript in
their browsers.

I think/hope this warning is obsolete. I can't imagine anything meaningful
in ASP.NET without javascript.

Eliyahu
 
A

Anders Norås [MCAD]

I think/hope this warning is obsolete. I can't imagine anything meaningful
in ASP.NET without javascript.

Personally I love JavaScript. When I did the JavaScript implmenation of the
XmlSerializer class
(http://dotnetjunkies.com/WebLog/anoras/archive/2004/08/13/21962.aspx)
earlier this year some people even thought I had become obsessed with it.
However, there are some people who don't share my enthusiasm. There are some
organizations, such as military and financial institutions, who configure
their browsers with scripting switched off. Therefore one should be aware
that you cannot take script support for granted. Therefore the warning is in
place, but lack of script support is rarly an issue.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 

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,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top