Imar,
Here is a copy of my current code. I also had to change the name of sub from SendButton to just Send because your instructions said to name it Send.
Protected Sub Send_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Send.Click
As I mentioned, I also Dimensioned FormTable and initialiized it to True (Boolean)
Dim FormTable As Object
FormTable = True
At the bottom of the routine, I have commented out FormTable.Visible
' FormTable.Visible = False '
Imports System.IO ' Provides access to the File class for reading the file
Imports System.Net.Mail ' Provides access to the various mail related classes
Partial Class Controls_ContactForm
Inherits System.Web.UI.UserControl
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
If Not String.IsNullOrEmpty(PhoneHome.Text) Or Not String.IsNullOrEmpty(PhoneBusiness.Text) Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
Protected Sub Send_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Send.Click
If Page.IsValid Then
Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
Dim mailBody As String = File.ReadAllText(fileName)
Dim FormTable As Object
FormTable = True
mailBody = mailBody.Replace("##Name##", Name.Text)
mailBody = mailBody.Replace("##Email##", EmailAddress.Text)
mailBody = mailBody.Replace("##HomePhone##", PhoneHome.Text)
mailBody = mailBody.Replace("##BusinessPhone##", PhoneBusiness.Text)
mailBody = mailBody.Replace("##Comments##", Comments.Text)
Dim myMessage As MailMessage = New MailMessage()
myMessage.Subject = "Response from web site"
myMessage.Body = mailBody
myMessage.From = New MailAddress("
[email protected]", "Jack Koyle")
myMessage.To.Add(New MailAddress("
[email protected]", "Jack Koyle"))
Dim mySmtpClient As SmtpClient = New SmtpClient()
mySmtpClient.Send(myMessage)
Message.Visible = True
' FormTable.Visible = False '
End If
End Sub
End Class
Please advise me on what I've done wrong. I have tried to follow your book exactly.
Thank You,
jkoyle
Michigan, USA