Solved

prevent  multiple form submission

Posted on 2006-06-22
2
210 Views
Last Modified: 2010-04-23
I have a 1 btnSubmit button that sends an email. users do multiple clicks and we receive all emails. How to avoid this? I did a research and tried a few codes but non of them worked.

This is my code for the button:

-------------------------------------------------------

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        Try
            Dim objMail As New MailMessage
            objMail.From = "email1"
            objMail.To = "email2"
            objMail.Subject = "Form"
            objMail.BodyFormat = MailFormat.Html
         
            objMail.Body = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
                & "<body>" & vbCrLf _
                 & "</body>" & vbCrLf _
                & "</html>" & vbCrLf

            SmtpMail.SmtpServer = "192.100.00.104"

            SmtpMail.Send(objMail)

        Catch ex As Exception
         
            lblError.Visible = True
            lblError.Text = ex.Message

        End Try

-----------------------------------------------------------------------------------------


thanks,
0
Comment
Question by:ainaks25
[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
2 Comments
 

Author Comment

by:ainaks25
ID: 16963301
I found the solution:

<SCRIPT language=JavaScript > 

var submitcount=0;

function checkSubmit()
{

if (submitcount == 0)
{ submitcount++; return true; }
else
{ alert('This form has already been submitted.' ); return false; }

}

</SCRIPT>       



and

<form id="Form1" name="MainForm" method="post" runat="server" onSubmit=" return checkSubmit();" >


---------------------------
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 16997904
Question closed - 125 points refunded.

Best regards,
RomMod
Experts Exchange
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

688 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