How do I put the following code into a code behind file? Do I just copy and paste it?
Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="utf-8" %>
<%@ import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub btnReset_Click(s As Object, e As EventArgs)
Title.SelectedItem.Text = ""
Forename.Text = ""
Surname.Text = ""
Email_Address.Text = ""
Telephone.Text = ""
Call_Day.Text = ""
Calendar.SelectedDates.Clear()
Call_Time.SelectedItem.Text = ""
OptOut.Checked = True
End Sub
Sub btnSubmit_Click(s As Object, e As EventArgs)
Dim conRubicCallBack As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand
conRubicCallBack = New SqlConnection("Server=xx;UID=xxx;PWD=xxx;database=db226743166" )
strInsert = "Insert tblCallbacks (Title, Forename, Surname, EmailAddress, TelephoneNumber, DaytoCall, TimetoCall, OptOut) Values (@Title, @Forename, @Surname, @EmailAddress, @TelephoneNumber, @DaytoCall, @TimetoCall, @OptOut)"
cmdInsert = New SqlCommand(strInsert, conRubicCallBack)
cmdInsert.Parameters.Add( "@Title", Title.SelectedItem.Text)
cmdInsert.Parameters.Add( "@Forename", Forename.Text)
cmdInsert.Parameters.Add( "@Surname", Surname.Text)
cmdInsert.Parameters.Add( "@EmailAddress", Email_Address.Text)
cmdInsert.Parameters.Add( "@TelephoneNumber", Telephone.Text)
cmdInsert.Parameters.Add( "@DaytoCall", SqlDbType.DateTime).Value = Call_Day.Text
cmdInsert.Parameters.Add( "@TimetoCall", Call_Time.SelectedItem.Text)
cmdInsert.Parameters.Add( "@OptOut", SqlDbType.bit).Value = OptOut.Checked
conRubicCallBack.Open()
cmdInsert.ExecuteNonQuery()
conRubicCallBack.Close()
panelSendEmail.Visible = false
panelMailSent.Visible = true
doEmailClient
Response.AddHeader("Refresh","5;url=index.html")
End Sub
Sub doEmailClient
Dim objMail as New MailMessage
objMail.To = Email_Address.Text
objMail.From = "noreply@rubicsolutions.co.uk"
objMail.CC = "gavin.egdell@rubicsolutions.co.uk"
objMail.Subject="Your callback details"
objMail.Body = "<html><head><title>Please call me back</title></head><body>"+"<p>Title: "+Title.SelectedItem.Text+"</p>"+"<p>Name: "+Forename.Text+"</p>"+"<p>Surname: "+ Surname.Text+"</p>"+"<p>Email: "+Email_Address.Text+"</p>"+"<p>Telephone: "+Telephone.Text+"</p>"+"<p>Date: "+Call_Day.Text+"</p>"+"<p>Time: "+Call_Time.SelectedItem.Text+"</p>"+"</body></html>"
objMail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "mrvnet.kundenserver.de"
SmtpMail.Send(objMail)
End Sub
Private Sub Calendar_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)
' define a new Style for the current date
Dim todayStyle As New Style()
todayStyle.BackColor = System.Drawing.Color.Navy
todayStyle.ForeColor = System.Drawing.Color.White
If e.Day.IsToday Then
' apply the todayStyle style to the current style dynamically
e.Cell.ApplyStyle(todayStyle)
End If
End Sub
Private Sub Calendar_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Call_Day.Text = Calendar.SelectedDate.ToShortDateString()
End Sub