473,378 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Button click once

Hi All,
I'm trying to create a button that once clicked will disable itself (so as
not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am I doing
wrong?

If I remove the line it posts back fine.

Thanks
Jon

Nov 18 '05 #1
5 3472
Hi
Place button1.enabled = false on the button click event. This will disable
the button after postback, because, the click event is only processed after
postback. Thanks
Ibrahim

"Jon Booth" wrote:
Hi All,
I'm trying to create a button that once clicked will disable itself (so as
not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am I doing
wrong?

If I remove the line it posts back fine.

Thanks
Jon

Nov 18 '05 #2
Jos
Jon Booth wrote:
Hi All,
I'm trying to create a button that once clicked will disable itself
(so as not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am I
doing wrong?

If I remove the line it posts back fine.


It disables the button before the actual postback, which is hence aborted.

I saw a similar post a few weeks ago, and I remember that
one of the solutions was to use visibility instead of disabled.
(document.Form1.Button1.style.visibility='hidden'; ).

--

Jos
Nov 18 '05 #3
Hi Jon,

You might also want to investigate this technique:

http://www.metabuilders.com/Tools/OneClick.aspx

"Jon Booth" <jo*******@nusystems.com.au> wrote in message
news:uJ**************@TK2MSFTNGP10.phx.gbl...
Hi All,
I'm trying to create a button that once clicked will disable itself (so as
not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am I doing
wrong?

If I remove the line it posts back fine.

Thanks
Jon


Nov 18 '05 #4

Jon Booth wrote:
*Hi All,
I'm trying to create a button that once clicked will disable itsel
(so as
not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am
doing
wrong?

If I remove the line it posts back fine.

Thanks
Jon *


you want the button to be used only once? (and your button i
performing some action which requires a postback, is it?)

then just put this portion of code at the end of the button clic
event.

me.enable = false

By the way, is it a HTML button or a ASP.NET button
-
weichun
-----------------------------------------------------------------------
Posted via http://www.codecomments.co
-----------------------------------------------------------------------

Nov 18 '05 #5
Thanks for the advice.
I've extended your suggestion of using styles. I have a second html button
that is disabled and hidden. When the user clicks the asp button its hidden
and the html button is displayed.

Button1.Attributes.Add("onClick","document.Form1.B utton1.style.display='none
';document.Form1.Button2.style.display='block';");

I wanted to do it client side because I didn't want them to click it twice
by accident. rarely someon may want to submit twice in which case they can
go back to the page and do it.

Thanks for your help
Jon

"Jos" <jo***************@fastmail.fm> wrote in message
news:ui*************@TK2MSFTNGP12.phx.gbl...
Jon Booth wrote:
Hi All,
I'm trying to create a button that once clicked will disable itself
(so as not to be clicked twice)

I have the following in my cs
Button1.Attributes.Add("onClick","return
document.Form1.Button1.disabled=true;");

It disables the button but does not perform the post back. What am I
doing wrong?

If I remove the line it posts back fine.


It disables the button before the actual postback, which is hence aborted.

I saw a similar post a few weeks ago, and I remember that
one of the solutions was to use visibility instead of disabled.
(document.Form1.Button1.style.visibility='hidden'; ).

--

Jos

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Yaqian Fang | last post by:
Hi, could anyone please tell me how to make a button look like "being clicked"? A button picture always looks static, though a link is associated with it. Thank you.
8
by: Galahad | last post by:
Here's the question: I have a form w/ TextBox controls and a Search Button control. Once the user clicks the Search Button, they get a Modal dialog w/ a datagrid that contains their search...
6
by: Michael Johnson Jr. | last post by:
I am trying to handle a button click event, which updates a web control table with data. The button is dynamically created in the table itself. When I call updateTable() in the Page_Load the new...
8
by: Lee | last post by:
Hi,I'm trying to have a button that fires a click event only once. What is the best way to do so that after the first button click, any the following clicks will be ignored.
3
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called...
16
by: Barry Gilmore | last post by:
Is there a way to disable a button after it is clicked? I am trying to avoid having someone click on it twice while they wait for it to process. Thank you!
1
by: regelcom | last post by:
My son is trying to create an about form button for a form he has already created. Any help would be great. Thanks
9
by: mosscliffe | last post by:
I am sorry but I am all very new and slow at understanding all this ASP.NET2. I found some code which showed how to page with a repeater. All very excited as I had been looking for this all...
5
by: visu | last post by:
Hi this is a question asked in this group two years back.. No answer for this question till date. now i am in the same situation of the questioner.. to find a solution for this problem. Can any...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.