Quote:
I don't suppose you could post some sample code I could shamelessly
plagerize?? |
If you're doing ASP.net, I strongly suggest you get VS.net. The validators
are built into that.
But, for a sample validataor:
..ASPX:
<asp:requiredfieldvalidator id=RequiredFieldValidator_Name runat="server"
enableclientscript="False" errormessage="<a href='#yourNameField'>Your name
is required</a>" controltovalidate="TextBox_name" font-bold="True"><img
src='/assets/icons_alert.gif' width='22' height='14' alt=''>Name
Required</asp:requiredfieldvalidator>
(there are all sorts of validator controls in .net...google to find more
about them)
And to send the mail:
Sub btnSubmitMessage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmitMessage.Click
'check for
'form validity and either show errors, or send message
Page.Validate()
If (Page.IsValid) Then
'send email
Dim EMServer As String
EMServer =
System.Configuration.ConfigurationSettings.AppSett ings("EmServer")
LblEmail.Text = objDataReader("email").ToString
LblContact.Text = objDataReader("contact").ToString & " - "
& objDataReader("description").ToString
strCustomSubject = trim(objDataReader("emailSubjectSuffix").ToString)
Dim MyMessage As New MailMessage
MyMessage.To = LblEmail.Text
MyMessage.From = TextBox_email.Text
MyMessage.Subject = TextBox_Subject.text
MyMessage.BodyFormat = MailFormat.Text
MyMessage.Body = "This message has been sent from the MJB website:"
& _
vbcrlf & "----------------------------------------------------------" & _
vbcrlf & "From: " & TextBox_name.text & _
vbcrlf & "Email: " & TextBox_email.text & _
vbcrlf & "Phone: " & TextBox_phone.text & _
vbcrlf & "================================================= =========" & _
vbcrlf & vbcrlf & TextBox_message.Text
SmtpMail.SmtpServer = EMServer
SmtpMail.Send(MyMessage)
Else 'page isn't valid
'don't send email
End If ' page.IsValid
End Sub