Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie button event firing on page load

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a submit button which fires when the page is first loaded.
the is vb.net code behind page, asp.net 2.0.
Code:
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        'If Not Page.IsPostBack Then
        Dim CrLf As String = Chr(13) & Chr(10)
        'save to database

        'send email to them saying this is subject to approval

        Dim EmailSubject, EmailBody As String
        EmailSubject = "Thank you for submitting your request to Robots2000"
        EmailBody = "Please allow 36hrs for completion of your request for R2-D2 to show up..." & CrLf
        EmailBody = EmailBody & "   at the " & DropDownList1.Text & " located at " & txtLocation.Text & CrLf
        EmailBody = EmailBody & "" & CrLf
        EmailBody = EmailBody & "You will be notified by an email sent to " & txtEmail.Text & " if you're request has been approved." & CrLf
        EmailBody = EmailBody & "" & CrLf
        EmailBody = EmailBody & "Please contact us Immediately if there is a Cancellation!"

        Try
            Dim message As New MailMessage("r2d2@robots2000.com", txtEmail.Text, EmailSubject, EmailBody)
            Dim emailClient As New SmtpClient("localhost")
            emailClient.Send(message)
            lblErrorStatus.Text = "Message Sent"
        Catch ex As Exception
            lblErrorStatus.Text = ex.ToString()
        End Try
        'End If
        'send email to me
    End Sub
any ideas?

DougP
[r2d2] < I Built one
 
This event should not fire unless the button is clicked.
Check to see if you have this event wired to another control etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top