Solved

prevent  multiple form submission

Posted on 2006-06-22
2
209 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get sourcecode path 14 58
Check only one toolstripmenu item 12 56
Click print button programmatically on print showdialog 1 22
Adding Rows to Grid 4 26
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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