Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Prevent Submit Button Clicked Twice.

Posted on 2004-08-20
3
Medium Priority
?
1,166 Views
Last Modified: 2012-06-21
Hi,

How to prevent user to click a submit button more than once?
I've seen some sites disabled the button once it's clicked. Could

somebody tells me how to do that? Or any other solutions?

Thanks in advance,

Hendry
0
Comment
Question by:MiBlg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
tovvenki earned 120 total points
ID: 11850490
Hi,
try this
in the code behind file
private void Page_Load(object sender, System.EventArgs e)
{

     btnSubmit.Attributes.Add("OnClick","javascript:disableButton();");
}

in the aspx file write this
<HTML>
<HEAD>
<title>MyTitle</title>
<script language="javascript">
function disableButton()
{

document.forms[0].SubmitButtton.disabled = true;
document.forms[0].submit();
}              
</script>
</HEAD>

if you still have problem with this technique then have a look at this article
http://www.codeproject.com/aspnet/ClickOnce_Button_Control.asp

Regards,
venki
0
 
LVL 10

Expert Comment

by:jnhorst
ID: 11853249
Another possibility is to set Enabled = false on the submit button, assuming the submit button is a server-side button control.  Do this on it's click event.

private void Button1_Click(object sender, System.EventArgs e)
{
     // code for whatever needs to be accomplished when the button is clicked.
     ... code here.

     // disable this button once the code has executed.
     Button1.Enabled = false;      
}

John
0
 

Assisted Solution

by:rasaraja
rasaraja earned 80 total points
ID: 11854494
Hi jnhorst,
      Sorry to point this out, but your solution won't work. The button_click() event is raised on the server, if the page takes time to submit, there is no way the button can be disabled . It has to be done on the client side, as tovvenki has suggested.

Hendry,
   You can do it the old way, too --

<HTML>
<HEAD>
<title>MyTitle</title>
<script language="javascript">
function disableButton(this)
{

this.disabled = true;
this.submit();
}              
</script>
</HEAD>

!------********-------- Decare the button-------********-------------

<input type=submit onclick="disablebutton(this)">

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question